diff options
Diffstat (limited to 'bin/leap')
-rwxr-xr-x | bin/leap | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -1,7 +1,10 @@ #!/usr/bin/env ruby -if ARGV.include?('--debug') +if ARGV.include?('--debug') || ARGV.include?('-d') + DEBUG=true require 'debugger' +else + DEBUG=false end begin @@ -18,7 +21,6 @@ rescue LoadError # This allows you to run the command directly while developing the gem, and also lets you # run from anywhere (I like to link 'bin/leap' to /usr/local/bin/leap). # - require 'rubygems' base_dir = File.expand_path('..', File.dirname(File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__)) require File.join(base_dir, 'lib','leap_cli','load_paths') require 'leap_cli' @@ -78,9 +80,27 @@ module LeapCli::Commands exit(0) end + # disable GLI error catching + ENV['GLI_DEBUG'] = "true" + def error_message(msg) + end + # load commands and run commands_from('leap_cli/commands') ORIGINAL_ARGV = ARGV.dup - exit_status = run(ARGV) - exit(LeapCli::Util.exit_status || exit_status) + begin + exit_status = run(ARGV) + exit(LeapCli::Util.exit_status || exit_status) + rescue StandardError => exc + if exc.respond_to? :log + exc.log + else + puts + LeapCli.log :error, "%s: %s" % [exc.class, exc.message] + puts + end + if DEBUG + raise exc + end + end end |