lib/clamp/command.rb in clamp-0.6.3 vs lib/clamp/command.rb in clamp-0.6.4
- old
+ new
@@ -101,10 +101,17 @@
e = UsageError.new(message, self)
e.set_backtrace(caller)
raise e
end
+ def signal_error(message, options = {})
+ status = options.fetch(:status, 1)
+ e = ExecutionError.new(message, self, status)
+ e.set_backtrace(caller)
+ raise e
+ end
+
def request_help
raise HelpWanted, self
end
class << self
@@ -128,9 +135,12 @@
$stderr.puts ""
$stderr.puts "See: '#{e.command.invocation_path} --help'"
exit(1)
rescue Clamp::HelpWanted => e
puts e.command.help
+ rescue Clamp::ExecutionError => e
+ $stderr.puts "ERROR: #{e.message}"
+ exit(e.status)
end
end
end