Class: Ibex::CLI
- Inherits:
-
Object
- Object
- Ibex::CLI
- Defined in:
- lib/ibex/cli.rb
Overview
Command-line pipeline coordinator. rubocop:disable Metrics/ClassLength -- inline type contracts add lines without adding runtime responsibilities.
Constant Summary collapse
- SUBCOMMAND_HANDLERS =
{ "check" => %i[CLIAmbiguity run_check_command], "diagnose" => %i[CLIDiagnostics run_diagnose_command], "coverage" => %i[CLICoverage run_coverage_command], "debug" => %i[CLIDebug run_debug_command], "doc" => %i[CLIDocumentation run_documentation_command], "errors" => %i[CLIErrorMessages run_error_messages_command], "explain" => %i[CLIExplain run_explain_command], "fmt" => %i[CLIFormatting run_format_command], "test" => %i[CLIGrammarTests run_grammar_tests_command], "lsp" => %i[CLILSP run_lsp_command], "migrate-check" => %i[CLIRaccMigration run_migrate_check_command], "migrate-harness" => %i[CLIRaccMigration run_migrate_harness_command], "samples" => %i[CLISamples run_samples_command], "validate-ir" => %i[CLIIRTools run_validate_ir_command], "compare" => %i[CLIIRTools run_compare_command], "migrate-ir" => %i[CLIIRTools run_migrate_ir_command] }.freeze
Constants included from CLIOutputs
Ibex::CLIOutputs::WARNING_MESSAGES
Constants included from CLICounterexampleOptions
Ibex::CLICounterexampleOptions::DEFAULTS
Class Method Summary collapse
-
.start(arguments, stdin: $stdin, stdout: $stdout, stderr: $stderr, watch_clock: nil, watch_sleeper: nil, watch_iteration_hook: nil) ⇒ Object
rubocop:disable Layout/LineLength.
Instance Method Summary collapse
-
#initialize(stdout:, stderr:, stdin: $stdin, watch_clock: nil, watch_sleeper: nil, watch_iteration_hook: nil) ⇒ CLI
constructor
A new instance of CLI.
- #run(arguments) ⇒ Object
Constructor Details
#initialize(stdout:, stderr:, stdin: $stdin, watch_clock: nil, watch_sleeper: nil, watch_iteration_hook: nil) ⇒ CLI
Returns a new instance of CLI.
153 154 155 156 157 158 159 160 161 162 |
# File 'lib/ibex/cli.rb', line 153 def initialize(stdout:, stderr:, stdin: $stdin, watch_clock: nil, watch_sleeper: nil, watch_iteration_hook: nil) @stdin = stdin @stdout = stdout @stderr = stderr @watch_clock = watch_clock || -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) } @watch_sleeper = watch_sleeper || ->(seconds) { sleep(seconds) } @watch_iteration_hook = watch_iteration_hook || ->(_event, _iteration, _paths) {} @options = { emit: "ruby", mode: :default, table: :compact, line_convert: true } .merge(CLICounterexampleOptions::DEFAULTS) end |
Class Method Details
.start(arguments, stdin: $stdin, stdout: $stdout, stderr: $stderr, watch_clock: nil, watch_sleeper: nil, watch_iteration_hook: nil) ⇒ Object
rubocop:disable Layout/LineLength
144 145 146 147 148 149 150 |
# File 'lib/ibex/cli.rb', line 144 def self.start(arguments, stdin: $stdin, stdout: $stdout, stderr: $stderr, watch_clock: nil, watch_sleeper: nil, watch_iteration_hook: nil) new( stdin: stdin, stdout: stdout, stderr: stderr, watch_clock: watch_clock, watch_sleeper: watch_sleeper, watch_iteration_hook: watch_iteration_hook ).run(arguments) end |
Instance Method Details
#run(arguments) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/ibex/cli.rb', line 166 def run(arguments) subcommand = dispatch_subcommand(arguments) return subcommand unless subcommand.nil? parser = option_parser remaining = parser.parse(arguments) information = informational_result(parser) return information unless information.nil? path = input_path(remaining) validate_generation_paths!(path) if @options[:watch] run_watch_feature(path) else process_grammar(path) end rescue OptionParser::ParseError, Ibex::Error, SystemCallError, SystemStackError => e @stderr.puts(e.) 1 end |