Class: 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
-
#run ⇒ Integer
CLI exit status.
Methods inherited from Command
Constructor Details
This class inherits a constructor from Rigor::CLI::Command
Instance Method Details
#run ⇒ Integer
Returns CLI exit status.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rigor/cli/explain_command.rb', line 25 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 |