Parse :arguments_required as part of the options of a command.
This commit is contained in:
parent
7815897507
commit
ac63605180
|
@ -137,12 +137,17 @@ class Pry
|
||||||
# @raise [NoCommandError] If the command is not defined in this set
|
# @raise [NoCommandError] If the command is not defined in this set
|
||||||
def run_command(context, name, *args)
|
def run_command(context, name, *args)
|
||||||
context.extend helper_module
|
context.extend helper_module
|
||||||
|
command = commands[name]
|
||||||
|
|
||||||
if command = commands[name]
|
if command.nil?
|
||||||
command.call(context, *args)
|
|
||||||
else
|
|
||||||
raise NoCommandError.new(name, self)
|
raise NoCommandError.new(name, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if args.size < command.options[:arguments_required].to_i
|
||||||
|
puts "The command '#{command.name}' requires #{command.options[:arguments_required]} argument(s)."
|
||||||
|
else
|
||||||
|
command.call(context, *args)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets the description for a command (replacing the old
|
# Sets the description for a command (replacing the old
|
||||||
|
|
Loading…
Reference in New Issue