mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Move command options Proc under Command namespace
Because it fits better there and is also hidden from the user. Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
This commit is contained in:
parent
ebccd57013
commit
6f7e483884
3 changed files with 16 additions and 16 deletions
13
lib/pry.rb
13
lib/pry.rb
|
@ -130,19 +130,6 @@ 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
|
||||
|
|
|
@ -37,7 +37,7 @@ class Pry
|
|||
|
||||
# Define or get the command's options
|
||||
def command_options(arg=nil)
|
||||
@command_options ||= Pry::DEFAULT_COMMAND_OPTIONS.call(match)
|
||||
@command_options ||= DEFAULT_OPTIONS.call(match)
|
||||
@command_options.merge!(arg) if arg
|
||||
@command_options
|
||||
end
|
||||
|
@ -196,6 +196,19 @@ class Pry
|
|||
end
|
||||
end
|
||||
|
||||
DEFAULT_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
|
||||
|
||||
# Properties of one execution of a command (passed by {Pry#run_command} as a hash of
|
||||
# context and expanded in `#initialize`
|
||||
attr_accessor :output
|
||||
|
|
|
@ -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 = Pry::DEFAULT_COMMAND_OPTIONS.call(match).merge!(options)
|
||||
options = Pry::Command::DEFAULT_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 = Pry::DEFAULT_COMMAND_OPTIONS.call(match).merge!(options)
|
||||
options = Pry::Command::DEFAULT_OPTIONS.call(match).merge!(options)
|
||||
|
||||
commands[match] = Pry::ClassCommand.subclass(match, description, options, helper_module, &block)
|
||||
commands[match].class_eval(&block)
|
||||
|
|
Loading…
Reference in a new issue