From ac636051800d57116a62918cf7154e31be7bbfa5 Mon Sep 17 00:00:00 2001 From: Rob Gleeson Date: Wed, 11 May 2011 11:28:41 +0100 Subject: [PATCH] Parse :arguments_required as part of the options of a command. --- lib/pry/command_set.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb index 71bcde83..b7209516 100644 --- a/lib/pry/command_set.rb +++ b/lib/pry/command_set.rb @@ -137,12 +137,17 @@ class Pry # @raise [NoCommandError] If the command is not defined in this set def run_command(context, name, *args) context.extend helper_module + command = commands[name] - if command = commands[name] - command.call(context, *args) - else + if command.nil? raise NoCommandError.new(name, self) 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 # Sets the description for a command (replacing the old