pry--pry/lib/pry/extended_commands/user_command_api.rb

23 lines
551 B
Ruby
Raw Normal View History

class Pry
module ExtendedCommands
UserCommandAPI = Pry::CommandSet.new do
command "define-command", "Define a command in the session, use same syntax as `command` method for command API" do |arg|
next output.puts("Provide an arg!") if arg.nil?
prime_string = "command #{arg_string}\n"
command_string = Pry.active_instance.r(target, prime_string)
eval_string.replace <<-HERE
_pry_.commands.instance_eval do
#{command_string}
end
HERE
end
end
end
end