#!/usr/bin/env ruby
-if ARGV.include?('--debug')
+if ARGV.include?('--debug') || ARGV.include?('-d')
+ DEBUG=true
require 'debugger'
+else
+ DEBUG=false
end
begin
exit_status = run(ARGV)
exit(LeapCli::Util.exit_status || exit_status)
rescue StandardError => exc
- if LeapCli.log_level < 2
- if exc.respond_to? :log
- exc.log
- else
- puts "%s: %s" % [exc.class, exc.message]
- end
+ 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
switch :yes, :negatable => false
desc 'Enable debugging library (leap_cli development only)'
- switch :debug, :negatable => false
+ switch [:d, :debug], :negatable => false
desc 'Disable colors in output'
default_value true
Util::log "offending string: #{value}", :indent => 1
Util::log "error message: no file '#{exc}'", :indent => 1
end
- raise exc if LeapCli.log_level >= 2
+ raise exc if DEBUG
end
rescue AssertionFailed => exc
Util.bail! do
Util::log :failed, "assertion while evaluating node '#{self.name}'"
Util::log 'assertion: %s' % exc.assertion, :indent => 1
Util::log "offending key: #{key}", :indent => 1
- raise exc if LeapCli.log_level >= 2
+ raise exc if DEBUG
end
rescue SyntaxError, StandardError => exc
Util::bail! do
Util::log "offending key: #{key}", :indent => 1
Util::log "offending string: #{value}", :indent => 1
Util::log "error message: #{exc.inspect}", :indent => 1
- raise exc if LeapCli.log_level >= 2
+ raise exc if DEBUG
end
end