bin/trocla in trocla-0.0.12 vs bin/trocla in trocla-0.1.0
- old
+ new
@@ -4,11 +4,11 @@
require 'rubygems'
require 'trocla'
require 'optparse'
require 'yaml'
-options = { :config_file => nil, :ask_password => true }
+options = { :config_file => nil, :ask_password => true, :trace => false }
OptionParser.new do |opts|
opts.on("--version", "-V", "Version information") do
puts Trocla::VERSION::STRING
exit
@@ -21,10 +21,14 @@
STDERR.puts "Cannot find config file: #{v}"
exit 1
end
end
+ opts.on("--trace", "Show stack trace on failure") do
+ options[:trace] = true
+ end
+
opts.on("--no-random") do
options['random'] = false
end
opts.on("--length LENGTH") do |v|
@@ -109,10 +113,14 @@
begin
if result = send(action,options)
puts result.is_a?(String) ? result : result.inspect
end
rescue Exception => e
- STDERR.puts "Action failed with the following message: #{e.message}" unless e.message == 'exit'
+ unless e.message == 'exit'
+ STDERR.puts "Action failed with the following message: #{e.message}"
+ STDERR.puts "(See full trace by running task with --trace)"
+ end
+ raise e if options[:trace]
exit 1
end
else
STDERR.puts "Please supply one of the following actions: #{actions.join(', ')}"
exit 1