2011-06-02 11:22:59 -04:00
|
|
|
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2011-01-20 09:41:41 -05:00
|
|
|
|
2011-01-21 04:17:12 -05:00
|
|
|
# Inherit standard command set, but tweak them by importing some and
|
|
|
|
# overriding others.
|
|
|
|
# Illustrates use of `command`, `run`, and `import_from` commands.
|
2011-01-20 09:41:41 -05:00
|
|
|
class MyCommands < Pry::CommandBase
|
|
|
|
|
|
|
|
# Override ls command
|
|
|
|
command "ls", "An unhelpful ls" do
|
|
|
|
output.puts "No, i refuse to display any useful information."
|
|
|
|
end
|
|
|
|
|
2011-01-26 21:18:33 -05:00
|
|
|
# bring in just the status command from Pry::Commands
|
|
|
|
import_from Pry::Commands, "status"
|
|
|
|
|
2011-01-29 00:23:26 -05:00
|
|
|
# analogy to Ruby's native alias_method idiom for decorating a method
|
2011-09-18 02:36:39 -04:00
|
|
|
alias_command "old_status", "status"
|
2011-06-02 11:22:59 -04:00
|
|
|
|
2011-01-20 09:41:41 -05:00
|
|
|
# Invoke one command from within another using `run`
|
2011-01-26 21:18:33 -05:00
|
|
|
command "status", "Modified status." do |x|
|
2011-01-20 09:41:41 -05:00
|
|
|
output.puts "About to show status, are you ready?"
|
2011-01-26 21:18:33 -05:00
|
|
|
run "old_status", x
|
2011-01-20 09:41:41 -05:00
|
|
|
output.puts "Finished showing status."
|
|
|
|
end
|
|
|
|
|
2011-01-26 21:18:33 -05:00
|
|
|
# bring in a few other commands
|
2011-02-16 16:22:59 -05:00
|
|
|
import_from Pry::Commands, "quit", "show-method"
|
2011-01-20 09:41:41 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# Start a Pry session using the commands defined in MyCommands
|
|
|
|
# Type 'help' in Pry to get a list of the commands and their descriptions
|
|
|
|
Pry.start(TOPLEVEL_BINDING, :commands => MyCommands)
|