1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

added a few more commands to 'experimental' command set

This commit is contained in:
John Mair 2011-05-19 15:29:40 +12:00
parent 1be5786dc1
commit 746df39015

View file

@ -7,10 +7,43 @@ class Pry
output.puts opts[:eval_string]
end
command "power" do
instance_eval opts[:ni_arg_string]
end
command "play-string", "Play a string as input" do
Pry.active_instance.input = StringIO.new(opts[:arg_string])
end
command "play-method", "Play a method source as input" do |*args|
target = target()
opt = Slop.parse!(args) do |opt|
opt.banner "Usage: play-method [--replay START..END] [--clear] [--grep PATTERN] [--help]\n"
opt.on :l, :lines, 'The line (or range of lines) to replay.', true, :as => Range
opt.on :h, :help, "This message." do
output.puts opt
end
end
next if opt.help?
meth_name = args.shift
if (meth = get_method_object(meth_name, target, {})).nil?
output.puts "Invalid method name: #{meth_name}. Type `play-method --help` for help"
next
end
code, code_type = code_and_code_type_for(meth)
next if !code
slice = opt[:l] ? opt[:l] : (0..-1)
sliced_code = code.each_line.to_a[slice].join("\n")
Pry.active_instance.input = StringIO.new(sliced_code)
end
end
end
end