Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Start working on helpers--still playing. No tests yet

  • Loading branch information...
commit d57234b0f5d82371119d3328262d13580eb25a10 1 parent c9e5250
@pragdave authored
Showing with 9 additions and 2 deletions.
  1. +5 −1 lib/wanna/log.rb
  2. +4 −1 lib/wanna/option_store.rb
View
6 lib/wanna/log.rb
@@ -29,7 +29,11 @@ def self.log_with_timestamp(color, msg)
private
def self.colorize(color, msg)
- "\033[3#{COLOR_MAP[color]}m#{msg}\033[39m"
+ if Wanna::Options[:colorize]
+ "\033[3#{COLOR_MAP[color]}m#{msg}\033[39m"
+ else
+ msg
+ end
end
end
end
View
5 lib/wanna/option_store.rb
@@ -29,7 +29,8 @@ def validate(option, value)
VALID_OPTIONS = {
:tracing => OneOf.new(*Wanna::Log::LEVELS),
- :show_commands => Boolean.new
+ :show_commands => Boolean.new,
+ :colorize => Boolean.new,
} unless defined?(VALID_OPTIONS)
@@ -88,6 +89,8 @@ def initialize
# Set the default options. We could just use a hash literal, but this
# way we get parameter checking
set_default_option(:tracing, :errors)
+ set_default_option(:show_commands, true)
+ set_default_option(:colorize, !!(ENV['TERM'] && ENV['TERM'] =~ /color/i))
end
Please sign in to comment.
Something went wrong with that request. Please try again.