Class: Dry::CLI::Registry::Prefix
- Inherits:
-
Object
- Object
- Dry::CLI::Registry::Prefix
- Defined in:
- lib/dry/cli/registry.rb
Overview
Command name prefix
Instance Method Summary collapse
-
#initialize(registry, prefix, aliases, hidden) ⇒ Prefix
constructor
private
A new instance of Prefix.
- #register(name, command = nil, aliases: [], hidden: false, &block) ⇒ Object
Constructor Details
#initialize(registry, prefix, aliases, hidden) ⇒ Prefix
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Prefix.
311 312 313 314 315 316 |
# File 'lib/dry/cli/registry.rb', line 311 def initialize(registry, prefix, aliases, hidden) @registry = registry @prefix = prefix registry.set(prefix, nil, aliases, hidden) end |
Instance Method Details
#register(name, command = nil, aliases: [], hidden: false, &block) ⇒ Object
321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/dry/cli/registry.rb', line 321 def register(name, command = nil, aliases: [], hidden: false, &block) command_name = "#{prefix} #{name}" registry.set(command_name, command, aliases, hidden) if block_given? prefix = self.class.new(registry, command_name, aliases, hidden) if block.arity.zero? prefix.instance_eval(&block) else yield(prefix) end end end |