Class: Rigor::CLI::SigGenCommand
- Defined in:
- lib/rigor/cli/sig_gen_command.rb,
sig/rigor/cli/sig_gen_command.rbs
Overview
Executes the rigor sig-gen command — ADR-14 slices 1–3.
Walks the given paths (or configuration.paths when none are supplied), classifies every reachable instance
method via SigGen::Generator, and either prints the resulting RBS skeletons / unified-style diffs
(--print, --diff; slice 1) or writes them to the project signature tree via SigGen::Writer
(--write; slice 2).
--write follows the established Ruby community convention: lib/foo/bar.rb → sig/foo/bar.rbs. New methods are
inserted into the matching class declaration just before its closing end; new classes are appended to the file;
non-existent target files are created. User-authored declarations are NEVER replaced unless --overwrite is set
AND the candidate is a tighter-return.
Parameter policy defaults to untyped. --params=observed (slice 3) opts in to caller-side observation
harvesting: the ObservationCollector walks --observe=PATH... (default spec/ when no flag is given AND a
spec/ directory exists), unions per-position arg types, and the generator emits the union per ADR-5 clause 2.
--params=observed-strict stays reserved-but-inert until the capability-role catalog ships (rejected with a usage
error so the surface stays stable).
Constant Summary collapse
- USAGE =
"Usage: rigor sig-gen [options] [paths]"- VALID_MODES =
%w[print diff write].freeze
- VALID_PARAM_POLICIES =
%w[untyped observed observed-strict].freeze
- VALID_FORMATS =
%w[text json].freeze
Instance Method Summary collapse
-
#initialize ⇒ SigGenCommand
constructor
A new instance of SigGenCommand.
-
#run ⇒ Integer
CLI exit status.
Constructor Details
#initialize ⇒ SigGenCommand
Returns a new instance of SigGenCommand.
2 |
# File 'sig/rigor/cli/sig_gen_command.rbs', line 2
def initialize: (argv: untyped, out: untyped, err: untyped) -> void
|
Instance Method Details
#run ⇒ Integer
Returns CLI exit status.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rigor/cli/sig_gen_command.rb', line 37 def run = return CLI::EXIT_USAGE if .nil? configuration = Configuration.load(.fetch(:config)) paths = @argv.empty? ? configuration.paths : @argv observations = collect_observations(configuration, ) candidates = SigGen::Generator.new(configuration: configuration, paths: paths, observations: observations, include_private: .fetch(:include_private)).run mode = .fetch(:mode).to_sym if mode == :write dispatch_write(candidates, configuration, ) else dispatch_print_or_diff(candidates, mode, ) end 0 end |