2011-05-11 09:39:15 +00:00
|
|
|
class Pry
|
2011-05-15 17:31:07 +00:00
|
|
|
module ExtendedCommands
|
2011-05-11 09:39:15 +00:00
|
|
|
|
|
|
|
UserCommandAPI = Pry::CommandSet.new do
|
|
|
|
|
2011-06-16 13:50:19 +00:00
|
|
|
command "define-command", "Define a command in the session, use same syntax as `command` method for command API" do |arg|
|
2011-05-11 09:39:15 +00:00
|
|
|
next output.puts("Provide an arg!") if arg.nil?
|
|
|
|
|
2011-05-30 03:57:06 +00:00
|
|
|
prime_string = "command #{arg_string}\n"
|
2011-05-11 09:39:15 +00:00
|
|
|
command_string = Pry.active_instance.r(target, prime_string)
|
|
|
|
|
2011-05-30 03:57:06 +00:00
|
|
|
eval_string.replace <<-HERE
|
2011-05-11 09:39:15 +00:00
|
|
|
_pry_.commands.instance_eval do
|
|
|
|
#{command_string}
|
|
|
|
end
|
|
|
|
HERE
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|