-
Notifications
You must be signed in to change notification settings - Fork 49
/
rescue
executable file
·48 lines (41 loc) · 1.05 KB
/
rescue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env ruby
USAGE = %{
rescue (pry-rescue wrapper)
Usage:
rescue [--peek] <script.rb> [arguments...]
What it does:
Runs <script.rb>, and if an uncaught exception is raised,
pry will come to the rescue, giving you a pry prompt in the
context where the exception was raised.
You can then poke around to figure out why your code broke!
If --peek is specified, then you can hit <Ctrl+C> to interrupt
your program and open a pry session at any time you need.
See the README (http://bitly.com/pry-rescue) for more.
}
case ARGV[0]
when '-h', '--help'
puts USAGE
exit
when '--'
ARGV.shift
when /\A-/
puts USAGE
exit
when 'rails'
ENV['PRY_RESCUE_RAILS'] = 'true'
exec(*ARGV)
when /^re?spec|rake$/
ENV['SPEC_OPTS'] = "#{ENV['SPEC_OPTS']} -r pry-rescue/rspec"
exec(*ARGV)
end
if script = ARGV.shift
$0 = File.expand_path(script)
if File.exists? script
require File.expand_path('../../lib/pry-rescue.rb', __FILE__)
PryRescue.load $0
else
$stderr.puts "Error: #{script.inspect} not found."
end
else
puts USAGE
end