Skip to content

Commit

Permalink
Start working on helpers--still playing. No tests yet
Browse files Browse the repository at this point in the history
  • Loading branch information
pragdave committed Dec 29, 2009
1 parent c9e5250 commit d57234b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/wanna/log.rb
Expand Up @@ -29,7 +29,11 @@ def self.log_with_timestamp(color, msg)


private private
def self.colorize(color, msg) 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 end
end end
5 changes: 4 additions & 1 deletion lib/wanna/option_store.rb
Expand Up @@ -29,7 +29,8 @@ def validate(option, value)


VALID_OPTIONS = { VALID_OPTIONS = {
:tracing => OneOf.new(*Wanna::Log::LEVELS), :tracing => OneOf.new(*Wanna::Log::LEVELS),
:show_commands => Boolean.new :show_commands => Boolean.new,
:colorize => Boolean.new,
} unless defined?(VALID_OPTIONS) } unless defined?(VALID_OPTIONS)




Expand Down Expand Up @@ -88,6 +89,8 @@ def initialize
# Set the default options. We could just use a hash literal, but this # Set the default options. We could just use a hash literal, but this
# way we get parameter checking # way we get parameter checking
set_default_option(:tracing, :errors) set_default_option(:tracing, :errors)
set_default_option(:show_commands, true)
set_default_option(:colorize, !!(ENV['TERM'] && ENV['TERM'] =~ /color/i))
end end




Expand Down

0 comments on commit d57234b

Please sign in to comment.