Class: Textus::Surfaces::CLI::Runner::Base
- Defined in:
- lib/textus/surfaces/cli/runner.rb
Overview
Subclassable base for contract-projected verbs. Carries the verb’s contract (class attr ‘spec`) and the generic dispatch, exposing one overridable seam, #invoke, that defaults to the generic projection. Escape-hatch verbs subclass this and override #invoke to add behavior (suggestions, –stdin, BuildLock, multi-dispatch) WITHOUT restating the verb name — `spec.verb` remains the single source of dispatch.
Class Attribute Summary collapse
-
.spec ⇒ Object
Returns the value of attribute spec.
Attributes inherited from Verb
Class Method Summary collapse
-
.command_name(name = nil) ⇒ Object
ADR 0064: derive the CLI command name from the contract’s cli_leaf when not set explicitly, so an escape-hatch class never restates its own name.
Instance Method Summary collapse
- #call(store) ⇒ Object
- #flag_values(s = spec) ⇒ Object
-
#invoke(store) ⇒ Object
Default: pure contract projection.
- #spec ⇒ Object
Methods inherited from Verb
descendants, #emit, #gate_dispatch, inherited, #initialize, needs_store?, option, options, parent_group, #parse, #resolved_role
Constructor Details
This class inherits a constructor from Textus::Surfaces::CLI::Verb
Class Attribute Details
.spec ⇒ Object
Returns the value of attribute spec.
16 17 18 |
# File 'lib/textus/surfaces/cli/runner.rb', line 16 def spec @spec end |
Class Method Details
.command_name(name = nil) ⇒ Object
ADR 0064: derive the CLI command name from the contract’s cli_leaf when not set explicitly, so an escape-hatch class never restates its own name. The reconciliation spec proves command_name == cli_leaf for every such class, so this is an equivalence, not a behavior change.
22 23 24 25 26 |
# File 'lib/textus/surfaces/cli/runner.rb', line 22 def command_name(name = nil) return super if name super() || spec&.cli_leaf end |
Instance Method Details
#call(store) ⇒ Object
31 32 33 |
# File 'lib/textus/surfaces/cli/runner.rb', line 31 def call(store) invoke(store) end |
#flag_values(s = spec) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/textus/surfaces/cli/runner.rb', line 40 def flag_values(s = spec) s.args.reject(&:positional).each_with_object({}) do |a, h| raw = respond_to?(a.name) ? public_send(a.name) : nil next if raw.nil? h[a.name] = Runner.coerce(a, raw) end end |
#invoke(store) ⇒ Object
Default: pure contract projection. Override in subclasses for behavior.
36 37 38 |
# File 'lib/textus/surfaces/cli/runner.rb', line 36 def invoke(store) Runner.dispatch(self, store, spec) end |
#spec ⇒ Object
29 |
# File 'lib/textus/surfaces/cli/runner.rb', line 29 def spec = self.class.spec |