Class: Rigor::CLI::ExplainCommand
- Defined in:
- lib/rigor/cli/explain_command.rb,
sig/rigor/cli/explain_command.rbs
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 ⇒ ExplainCommand
constructor
A new instance of ExplainCommand.
-
#run ⇒ Integer
CLI exit status.
Constructor Details
#initialize ⇒ ExplainCommand
Returns a new instance of ExplainCommand.
2 |
# File 'sig/rigor/cli/explain_command.rbs', line 2
def initialize: (argv: untyped, out: untyped, err: untyped) -> void
|
Instance Method Details
#run ⇒ Integer
Returns CLI exit status.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rigor/cli/explain_command.rb', line 22 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 |