Move default command options to its own Proc

First of all, the `CommandSet#default_options` doesn't really belong to
the CommandSet. Secondly, I will use the command options from other
place, but later. Stay tuned!

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
This commit is contained in:
Kyrylo Silin 2012-12-25 21:57:08 +02:00
parent 5cb356f731
commit 177a0b5ef8
2 changed files with 15 additions and 17 deletions

View File

@ -130,6 +130,19 @@ class Pry
end
end
Pry::DEFAULT_COMMAND_OPTIONS = proc do |match|
{
:requires_gem => [],
:keep_retval => false,
:argument_required => false,
:interpolate => true,
:shellwords => true,
:listing => (String === match ? match : match.inspect),
:use_prefix => true,
:takes_block => false
}
end
# Store the current working directory. This allows show-source etc. to work if
# your process has changed directory since boot. [Issue #675]
INITIAL_PWD = Dir.pwd

View File

@ -81,7 +81,7 @@ class Pry
# # number-N regex command
def block_command(match, description="No description.", options={}, &block)
description, options = ["No description.", description] if description.is_a?(Hash)
options = default_options(match).merge!(options)
options = Pry::DEFAULT_COMMAND_OPTIONS.call(match).merge!(options)
commands[match] = Pry::BlockCommand.subclass(match, description, options, helper_module, &block)
end
@ -113,7 +113,7 @@ class Pry
#
def create_command(match, description="No description.", options={}, &block)
description, options = ["No description.", description] if description.is_a?(Hash)
options = default_options(match).merge!(options)
options = Pry::DEFAULT_COMMAND_OPTIONS.call(match).merge!(options)
commands[match] = Pry::ClassCommand.subclass(match, description, options, helper_module, &block)
commands[match].class_eval(&block)
@ -362,21 +362,6 @@ class Pry
end.map{ |command| command + " " } + Bond::DefaultMission.completions
end
end
private
def default_options(match)
{
:requires_gem => [],
:keep_retval => false,
:argument_required => false,
:interpolate => true,
:shellwords => true,
:listing => (String === match ? match : match.inspect),
:use_prefix => true,
:takes_block => false
}
end
end
# Wraps the return result of process_commands, indicates if the