mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
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:
parent
5cb356f731
commit
177a0b5ef8
2 changed files with 15 additions and 17 deletions
13
lib/pry.rb
13
lib/pry.rb
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue