diff options
-rw-r--r-- | lib/leap_cli/commands/pre.rb | 5 | ||||
-rw-r--r-- | lib/leap_cli/log.rb | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/leap_cli/commands/pre.rb b/lib/leap_cli/commands/pre.rb index 318282d..4b62b5b 100644 --- a/lib/leap_cli/commands/pre.rb +++ b/lib/leap_cli/commands/pre.rb @@ -23,6 +23,10 @@ module LeapCli; module Commands desc 'Enable debugging library (leap_cli development only)' switch :debug, :negatable => false + desc 'Disable colors in output' + default_value true + switch 'color', :negatable => true + pre do |global,command,options,args| # # set verbosity @@ -62,6 +66,7 @@ module LeapCli; module Commands LeapCli.log_file = global[:log] || LeapCli.leapfile.log LeapCli::Util.log_raw(:log) { $0 + ' ' + ORIGINAL_ARGV.join(' ')} log_version + LeapCli.log_in_color = global[:color] # # load all the nodes everything diff --git a/lib/leap_cli/log.rb b/lib/leap_cli/log.rb index 4bdcc33..69e9f67 100644 --- a/lib/leap_cli/log.rb +++ b/lib/leap_cli/log.rb @@ -9,6 +9,8 @@ require 'paint' module LeapCli extend self + attr_accessor :log_in_color + # logging options def log_level @log_level ||= 1 @@ -112,8 +114,12 @@ module LeapCli message = LeapCli::Path.relative_path(message) end - log_raw(:log, nil) { [clear_prefix, message].join } - log_raw(:stdout, options[:indent]) { [colored_prefix, message].join } + log_raw(:log, nil) { [clear_prefix, message].join } + if LeapCli.log_in_color + log_raw(:stdout, options[:indent]) { [colored_prefix, message].join } + else + log_raw(:stdout, options[:indent]) { [clear_prefix, message].join } + end # run block, if given if block_given? |