lib/dry/cli/registry.rb in dry-cli-0.5.0 vs lib/dry/cli/registry.rb in dry-cli-0.5.1
- old
+ new
@@ -72,15 +72,20 @@
# prefix.register "app", Generate::App
# prefix.register "action", Generate::Action
# end
# end
# end
- def register(name, command = nil, aliases: [], **options)
+ def register(name, command = nil, aliases: [], &block)
if block_given?
- yield Prefix.new(@commands, name, aliases)
+ prefix = Prefix.new(@commands, name, aliases)
+ if block.arity.zero?
+ prefix.instance_eval(&block)
+ else
+ yield(prefix)
+ end
else
- @commands.set(name, command, aliases, **options)
+ @commands.set(name, command, aliases)
end
end
# Register a before callback.
#
@@ -306,12 +311,12 @@
end
# @since 0.1.0
#
# @see Dry::CLI::Registry#register
- def register(name, command, aliases: [], **options)
+ def register(name, command, aliases: [])
command_name = "#{prefix} #{name}"
- registry.set(command_name, command, aliases, **options)
+ registry.set(command_name, command, aliases)
end
private
# @since 0.1.0