aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-03-08 12:52:36 -0800
committerelijah <elijah@riseup.net>2014-03-08 12:52:36 -0800
commit3c0ce709ac6321a90f6daababb9b053b3e0cb756 (patch)
tree1e554e1d727302d81e3d358c725517045cab7f8c /lib
parent16c6cbae4f155c6f8c626fc69cca41ebee1a9e05 (diff)
downloadleap_cli-3c0ce709ac6321a90f6daababb9b053b3e0cb756.tar.gz
leap_cli-3c0ce709ac6321a90f6daababb9b053b3e0cb756.tar.bz2
added --no-color flag
Diffstat (limited to 'lib')
-rw-r--r--lib/leap_cli/commands/pre.rb5
-rw-r--r--lib/leap_cli/log.rb10
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?