From 6fda20a22fbc60d375a7c03c82701d9f96c7780c Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Sun, 18 Sep 2011 14:36:39 +0800 Subject: [PATCH] Remove the compulsary "" argument to alias_command --- examples/example_command_override.rb | 2 +- lib/pry/command_set.rb | 4 ++-- lib/pry/default_commands/context.rb | 8 ++++---- lib/pry/default_commands/documentation.rb | 2 +- lib/pry/default_commands/input.rb | 4 ++-- lib/pry/default_commands/introspection.rb | 4 ++-- lib/pry/default_commands/shell.rb | 2 +- test/test_command_set.rb | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/example_command_override.rb b/examples/example_command_override.rb index 237b1d61..1888e527 100644 --- a/examples/example_command_override.rb +++ b/examples/example_command_override.rb @@ -14,7 +14,7 @@ class MyCommands < Pry::CommandBase import_from Pry::Commands, "status" # 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` command "status", "Modified status." do |x| diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb index 3d409bb4..7900fff3 100644 --- a/lib/pry/command_set.rb +++ b/lib/pry/command_set.rb @@ -168,10 +168,10 @@ class Pry # @param [String] new_name New name of the command. # @param [String] old_name Old name 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].name = new_name - commands[new_name].description = desc if desc + commands[new_name].description = desc end # Runs a command. diff --git a/lib/pry/default_commands/context.rb b/lib/pry/default_commands/context.rb index 52f3d4f1..4c4b871e 100644 --- a/lib/pry/default_commands/context.rb +++ b/lib/pry/default_commands/context.rb @@ -91,7 +91,7 @@ class Pry throw(:breakout, target.eval(arg_string)) 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 if _pry_.binding_stack.one? @@ -111,15 +111,15 @@ class Pry end end - alias_command "quit", "exit", "" + alias_command "quit", "exit" command "exit-program", "End the current program. Aliases: quit-program, !!!" do Pry.save_history if Pry.config.history.should_save Kernel.exit target.eval(arg_string).to_i end - alias_command "quit-program", "exit-program", "" - alias_command "!!!", "exit-program", "" + alias_command "quit-program", "exit-program" + alias_command "!!!", "exit-program" command "!pry", "Start a Pry session on current self; this even works mid multi-line expression." do target.pry diff --git a/lib/pry/default_commands/documentation.rb b/lib/pry/default_commands/documentation.rb index 6accbbb5..15d9a7d8 100644 --- a/lib/pry/default_commands/documentation.rb +++ b/lib/pry/default_commands/documentation.rb @@ -52,7 +52,7 @@ class Pry 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| target = target() diff --git a/lib/pry/default_commands/input.rb b/lib/pry/default_commands/input.rb index 1c4c1e00..6b2de6c3 100644 --- a/lib/pry/default_commands/input.rb +++ b/lib/pry/default_commands/input.rb @@ -54,7 +54,7 @@ class Pry run "show-input" 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| opts = Slop.parse!(args) do |opt| @@ -270,7 +270,7 @@ class Pry end end - alias_command "history", "hist", "" + alias_command "history", "hist" helpers do def one_index_number(line_number) diff --git a/lib/pry/default_commands/introspection.rb b/lib/pry/default_commands/introspection.rb index a0f5cb2e..2a175d94 100644 --- a/lib/pry/default_commands/introspection.rb +++ b/lib/pry/default_commands/introspection.rb @@ -60,8 +60,8 @@ class Pry end end - alias_command "show-source", "show-method", "" - alias_command "$", "show-method", "" + alias_command "show-source", "show-method" + alias_command "$", "show-method" command "show-command", "Show the source for CMD. Type `show-command --help` for more info." do |*args| target = target() diff --git a/lib/pry/default_commands/shell.rb b/lib/pry/default_commands/shell.rb index 0987feca..e05da2e2 100644 --- a/lib/pry/default_commands/shell.rb +++ b/lib/pry/default_commands/shell.rb @@ -29,7 +29,7 @@ class Pry 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| start_line = 0 diff --git a/test/test_command_set.rb b/test/test_command_set.rb index ad396152..68a4aa0e 100644 --- a/test/test_command_set.rb +++ b/test/test_command_set.rb @@ -99,7 +99,7 @@ describe Pry::CommandSet do @set.alias_command 'bar', 'foo' @set.commands['bar'].name.should == 'bar' - @set.commands['bar'].description.should == 'stuff' + @set.commands['bar'].description.should == '' @set.run_command nil, 'bar' run.should == true