Skip to content

Commit c691b3c

Browse files
committed
Wrap tasks to handle Interrupt (i.e. Ctrl+C) to suppress unhandled error output.
1 parent 7cea20f commit c691b3c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

runx.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ def run(args)
1515
class TaskManager
1616
def initialize
1717
@tasks = {}
18-
@message = nil
18+
@doc = nil
1919
end
2020

21-
def doc(message)
22-
@message = message
21+
def doc(doc)
22+
@doc = doc
2323
end
2424

2525
def run(name, &block)
26-
@tasks[name.to_s.downcase] = Task.new(name.to_s, @message, block)
27-
@message = nil
26+
@tasks[name.to_s.downcase] = Task.new(name.to_s, @doc, block)
27+
@doc = nil
2828
end
2929

3030
attr_accessor :tasks
@@ -74,6 +74,10 @@ def find_runfile
7474
args = ARGV[1...ARGV.length]
7575
ARGV.clear
7676

77-
task.run(args)
77+
begin
78+
task.run(args)
79+
rescue Interrupt => e
80+
# Handle interrupt and exit.
81+
end
7882
end
7983
end

0 commit comments

Comments
 (0)