mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Remove the compulsary "" argument to alias_command
This commit is contained in:
parent
aaf0cac06b
commit
6fda20a22f
8 changed files with 14 additions and 14 deletions
|
@ -14,7 +14,7 @@ class MyCommands < Pry::CommandBase
|
||||||
import_from Pry::Commands, "status"
|
import_from Pry::Commands, "status"
|
||||||
|
|
||||||
# analogy to Ruby's native alias_method idiom for decorating a method
|
# analogy to Ruby's native alias_method idiom for decorating a method
|
||||||
alias_command "old_status", "status", ""
|
alias_command "old_status", "status"
|
||||||
|
|
||||||
# Invoke one command from within another using `run`
|
# Invoke one command from within another using `run`
|
||||||
command "status", "Modified status." do |x|
|
command "status", "Modified status." do |x|
|
||||||
|
|
|
@ -168,10 +168,10 @@ class Pry
|
||||||
# @param [String] new_name New name of the command.
|
# @param [String] new_name New name of the command.
|
||||||
# @param [String] old_name Old name of the command.
|
# @param [String] old_name Old name of the command.
|
||||||
# @param [String, nil] desc New description of the command.
|
# @param [String, nil] desc New description of the command.
|
||||||
def alias_command(new_name, old_name, desc = nil)
|
def alias_command(new_name, old_name, desc="")
|
||||||
commands[new_name] = commands[old_name].dup
|
commands[new_name] = commands[old_name].dup
|
||||||
commands[new_name].name = new_name
|
commands[new_name].name = new_name
|
||||||
commands[new_name].description = desc if desc
|
commands[new_name].description = desc
|
||||||
end
|
end
|
||||||
|
|
||||||
# Runs a command.
|
# Runs a command.
|
||||||
|
|
|
@ -91,7 +91,7 @@ class Pry
|
||||||
throw(:breakout, target.eval(arg_string))
|
throw(:breakout, target.eval(arg_string))
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_command "!!@", "exit-all", ""
|
alias_command "!!@", "exit-all"
|
||||||
|
|
||||||
command "exit", "Pop the current binding and return to the one immediately prior. Note this does NOT exit the program. Aliases: quit", :keep_retval => true do
|
command "exit", "Pop the current binding and return to the one immediately prior. Note this does NOT exit the program. Aliases: quit", :keep_retval => true do
|
||||||
if _pry_.binding_stack.one?
|
if _pry_.binding_stack.one?
|
||||||
|
@ -111,15 +111,15 @@ class Pry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_command "quit", "exit", ""
|
alias_command "quit", "exit"
|
||||||
|
|
||||||
command "exit-program", "End the current program. Aliases: quit-program, !!!" do
|
command "exit-program", "End the current program. Aliases: quit-program, !!!" do
|
||||||
Pry.save_history if Pry.config.history.should_save
|
Pry.save_history if Pry.config.history.should_save
|
||||||
Kernel.exit target.eval(arg_string).to_i
|
Kernel.exit target.eval(arg_string).to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_command "quit-program", "exit-program", ""
|
alias_command "quit-program", "exit-program"
|
||||||
alias_command "!!!", "exit-program", ""
|
alias_command "!!!", "exit-program"
|
||||||
|
|
||||||
command "!pry", "Start a Pry session on current self; this even works mid multi-line expression." do
|
command "!pry", "Start a Pry session on current self; this even works mid multi-line expression." do
|
||||||
target.pry
|
target.pry
|
||||||
|
|
|
@ -52,7 +52,7 @@ class Pry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_command "?", "show-doc", ""
|
alias_command "?", "show-doc"
|
||||||
|
|
||||||
command "stat", "View method information and set _file_ and _dir_ locals. Type `stat --help` for more info." do |*args|
|
command "stat", "View method information and set _file_ and _dir_ locals. Type `stat --help` for more info." do |*args|
|
||||||
target = target()
|
target = target()
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Pry
|
||||||
run "show-input"
|
run "show-input"
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_command(/%.?(-?\d+)?(?:\.\.(-?\d+))?/, /amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/, "")
|
alias_command(/%.?(-?\d+)?(?:\.\.(-?\d+))?/, /amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/)
|
||||||
|
|
||||||
command "play", "Play back a string variable or a method or a file as input. Type `play --help` for more information." do |*args|
|
command "play", "Play back a string variable or a method or a file as input. Type `play --help` for more information." do |*args|
|
||||||
opts = Slop.parse!(args) do |opt|
|
opts = Slop.parse!(args) do |opt|
|
||||||
|
@ -270,7 +270,7 @@ class Pry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_command "history", "hist", ""
|
alias_command "history", "hist"
|
||||||
|
|
||||||
helpers do
|
helpers do
|
||||||
def one_index_number(line_number)
|
def one_index_number(line_number)
|
||||||
|
|
|
@ -60,8 +60,8 @@ class Pry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_command "show-source", "show-method", ""
|
alias_command "show-source", "show-method"
|
||||||
alias_command "$", "show-method", ""
|
alias_command "$", "show-method"
|
||||||
|
|
||||||
command "show-command", "Show the source for CMD. Type `show-command --help` for more info." do |*args|
|
command "show-command", "Show the source for CMD. Type `show-command --help` for more info." do |*args|
|
||||||
target = target()
|
target = target()
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Pry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_command "file-mode", "shell-mode", ""
|
alias_command "file-mode", "shell-mode"
|
||||||
|
|
||||||
command "cat", "Show output of file FILE. Type `cat --help` for more information." do |*args|
|
command "cat", "Show output of file FILE. Type `cat --help` for more information." do |*args|
|
||||||
start_line = 0
|
start_line = 0
|
||||||
|
|
|
@ -99,7 +99,7 @@ describe Pry::CommandSet do
|
||||||
|
|
||||||
@set.alias_command 'bar', 'foo'
|
@set.alias_command 'bar', 'foo'
|
||||||
@set.commands['bar'].name.should == 'bar'
|
@set.commands['bar'].name.should == 'bar'
|
||||||
@set.commands['bar'].description.should == 'stuff'
|
@set.commands['bar'].description.should == ''
|
||||||
|
|
||||||
@set.run_command nil, 'bar'
|
@set.run_command nil, 'bar'
|
||||||
run.should == true
|
run.should == true
|
||||||
|
|
Loading…
Reference in a new issue