2012-08-11 20:22:29 -04:00
|
|
|
class Pry
|
|
|
|
# N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
|
2012-12-25 16:35:17 -05:00
|
|
|
class Command::RaiseUp < Pry::ClassCommand
|
2013-03-02 19:01:55 -05:00
|
|
|
match(/raise-up(!?\b.*)/)
|
2012-08-11 21:26:59 -04:00
|
|
|
group 'Context'
|
2012-12-25 16:35:17 -05:00
|
|
|
description 'Raise an exception out of the current pry instance.'
|
2012-08-11 21:26:59 -04:00
|
|
|
command_options :listing => 'raise-up'
|
|
|
|
|
2012-08-11 20:22:29 -04:00
|
|
|
banner <<-BANNER
|
2013-01-09 15:23:19 -05:00
|
|
|
Raise up, like exit, allows you to quit pry. Instead of returning a value
|
|
|
|
however, it raises an exception. If you don't provide the exception to be
|
|
|
|
raised, it will use the most recent exception (in pry `_ex_`).
|
2012-08-11 20:22:29 -04:00
|
|
|
|
2013-01-09 15:23:19 -05:00
|
|
|
When called as raise-up! (with an exclamation mark), this command raises the
|
|
|
|
exception through any nested prys you have created by "cd"ing into objects.
|
2012-08-11 20:22:29 -04:00
|
|
|
|
2013-01-09 15:23:19 -05:00
|
|
|
raise-up "get-me-out-of-here"
|
|
|
|
|
|
|
|
# This is equivalent to the command above.
|
|
|
|
raise "get-me-out-of-here"
|
|
|
|
raise-up
|
2012-08-11 20:22:29 -04:00
|
|
|
BANNER
|
|
|
|
|
|
|
|
def process
|
|
|
|
return stagger_output help if captures[0] =~ /(-h|--help)\b/
|
|
|
|
# Handle 'raise-up', 'raise-up "foo"', 'raise-up RuntimeError, 'farble' in a rubyesque manner
|
|
|
|
target.eval("_pry_.raise_up#{captures[0]}")
|
|
|
|
end
|
|
|
|
end
|
2012-12-25 16:35:17 -05:00
|
|
|
|
|
|
|
Pry::Commands.add_command(Pry::Command::RaiseUp)
|
2012-08-11 20:22:29 -04:00
|
|
|
end
|