Module: Ace::Support::Cli::RegistryDsl
- Defined in:
- lib/ace/support/cli/registry_dsl.rb
Overview
DSL adapter allowing CLI modules to keep ‘register` semantics while using Ace::Support::Cli::Registry under the hood.
Class Method Summary collapse
Instance Method Summary collapse
- #register(name, command_class = nil, *_args, aliases: nil, **_kwargs) ⇒ Object
- #resolve(args) ⇒ Object
Class Method Details
Instance Method Details
#register(name, command_class = nil, *_args, aliases: nil, **_kwargs) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/ace/support/cli/registry_dsl.rb', line 16 def register(name, command_class = nil, *_args, aliases: nil, **_kwargs) registry.register(name, normalize_command(command_class)) Array(aliases).each do |aliaz| registry.register(aliaz, normalize_command(command_class)) end self end |
#resolve(args) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/ace/support/cli/registry_dsl.rb', line 24 def resolve(args) return registry.resolve(args) unless args.empty? registry.resolve(["--help"]) rescue Ace::Support::Cli::CommandNotFoundError raise Ace::Support::Cli::Error.new("unknown command", exit_code: 1) end |