Class: Rigor::CLI::SigGenCommand
- Inherits:
-
Object
- Object
- Rigor::CLI::SigGenCommand
- Defined in:
- lib/rigor/cli/sig_gen_command.rb
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(argv:, out:, err:) ⇒ SigGenCommand
constructor
A new instance of SigGenCommand.
-
#run ⇒ Integer
CLI exit status.
Constructor Details
#initialize(argv:, out:, err:) ⇒ SigGenCommand
Returns a new instance of SigGenCommand.
44 45 46 47 48 |
# File 'lib/rigor/cli/sig_gen_command.rb', line 44 def initialize(argv:, out:, err:) @argv = argv @out = out @err = err end |
Instance Method Details
#run ⇒ Integer
Returns CLI exit status.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rigor/cli/sig_gen_command.rb', line 51 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 |