]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
only spit out stack trace if --debug
authorelijah <elijah@riseup.net>
Fri, 31 Oct 2014 23:56:46 +0000 (16:56 -0700)
committerelijah <elijah@riseup.net>
Fri, 31 Oct 2014 23:56:46 +0000 (16:56 -0700)
bin/leap
lib/leap_cli/commands/pre.rb
lib/leap_cli/config/object.rb
lib/leap_cli/util.rb

index 60671649150846c322702af7e186d526a3aa269f..c39da1c14031de2877799e29b0a8ebfbe75d99e3 100755 (executable)
--- a/bin/leap
+++ b/bin/leap
@@ -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
@@ -89,13 +92,14 @@ module LeapCli::Commands
     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
index 4bdeefea6a407466a6222b0ec310bcad9590dff6..7a64c15896664ce8df0d9f7819eca4b2b7cc0853 100644 (file)
@@ -21,7 +21,7 @@ module LeapCli; module Commands
   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
index 45144bcdd60860b6bf6c2e78a87ffa632702bdda..a0d402b36b110e606a5e7e98bdf238c0ea6f8dee 100644 (file)
@@ -293,14 +293,14 @@ module LeapCli
             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
@@ -308,7 +308,7 @@ module LeapCli
           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
 
index 43ff6f23971208023a615d5f38704f4f2e66f018..07ffcec0dfafd0f3f378154829f2a3b6b3c434fa 100644 (file)
@@ -30,6 +30,7 @@ module LeapCli
     #
     def bail!(*message)
       if block_given?
+        LeapCli.set_log_level(3)
         yield
       elsif message
         log 0, *message