1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/lib
Robert Gleeson c05c8f31c1 add Pry::CommandSet#[]=.
Pry::CommandSet#[]= can be used to re-assign commands or add new ones to
a command set. The key matches the pattern of a command you'd like to
replace and the value is the command you'd the pattern to be matched
with.

The key is really important. You could say this:

Pry.commands.command "hello" do
  output.puts "Hello! :)"
end
Pry.commands["help"] = Pry.commands["hello"]

I would expect "help" to print "Hello! :)", but the command is bound to
the pattern "hello". A new copy of the "hello" command is created
and the key is used as the match pattern, so "help" will print "Hello! :)".

You can use #[]= to replace commands, maybe your own 'help' implementation:
Pry.commands["help"] = MyHelpCommand

Commands can also be deleted by assigning a value of nil:
Pry.commands["help"] = nil

I decided to implement this based on SO post found here:
http://stackoverflow.com/questions/17475829/configure-help-output-in-pry
2013-09-22 09:43:24 +02:00
..
pry add Pry::CommandSet#[]=. 2013-09-22 09:43:24 +02:00
pry.rb Need the whitespace. 2013-09-11 13:51:45 -07:00