Class: Rigor::CLI::ExplainCommand
- Inherits:
-
Object
- Object
- Rigor::CLI::ExplainCommand
- Defined in:
- lib/rigor/cli/explain_command.rb
Overview
Executes ‘rigor explain <rule>`. Prints the catalog entry for one canonical rule id, a legacy alias, or a family wildcard (`call`, `flow`, `assert`, `dump`, `def`).
Without arguments lists every rule’s id and one-line summary.
The command is read-only: no parser, no analyzer, no I/O beyond the rendered catalog. Useful when a user sees a diagnostic in the editor and wants to know what the rule means without leaving the terminal.
Constant Summary collapse
- USAGE =
"Usage: rigor explain [options] [<rule>]"
Instance Method Summary collapse
-
#initialize(argv:, out:, err:) ⇒ ExplainCommand
constructor
A new instance of ExplainCommand.
-
#run ⇒ Integer
CLI exit status.
Constructor Details
#initialize(argv:, out:, err:) ⇒ ExplainCommand
Returns a new instance of ExplainCommand.
23 24 25 26 27 |
# File 'lib/rigor/cli/explain_command.rb', line 23 def initialize(argv:, out:, err:) @argv = argv @out = out @err = err end |
Instance Method Details
#run ⇒ Integer
Returns CLI exit status.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rigor/cli/explain_command.rb', line 30 def run = if @argv.empty? render_index(.fetch(:format)) return 0 end token = @argv.shift entries = Analysis::RuleCatalog.resolve(token) if entries.empty? @err.puts("Unknown rule: #{token}") @err.puts("Run `rigor explain` with no arguments to list every rule.") return CLI::EXIT_USAGE end render_entries(entries, .fetch(:format)) 0 end |