Class: Ibex::CLI::Command
- Inherits:
-
Object
- Object
- Ibex::CLI::Command
- Defined in:
- lib/ibex/cli.rb
Overview
A fixed command object keeps dispatch explicit while feature modules stay lazy.
Class Method Summary collapse
Instance Method Summary collapse
- #call(cli, arguments) ⇒ Object
-
#initialize(feature, runner: nil, &handler) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(feature, runner: nil, &handler) ⇒ Command
Returns a new instance of Command.
190 191 192 193 194 195 |
# File 'lib/ibex/cli.rb', line 190 def initialize(feature, runner: nil, &handler) @feature = feature @runner = runner @handler = handler freeze end |
Class Method Details
.object(runner) ⇒ Object
186 187 188 |
# File 'lib/ibex/cli.rb', line 186 def self.object(runner) new(nil, runner: runner) end |
Instance Method Details
#call(cli, arguments) ⇒ Object
198 199 200 201 202 203 204 |
# File 'lib/ibex/cli.rb', line 198 def call(cli, arguments) return @runner.call(Invocation.new(arguments: [*arguments], stdout: cli.stdout)) if @runner extension = FEATURE_LOADERS.fetch(@feature).call cli.extend(extension) unless cli.singleton_class.ancestors.include?(extension) cli.instance_exec(arguments, &@handler) end |