diff --git a/lib/foreman/cli.rb b/lib/foreman/cli.rb index 8a62b78..fbf74e2 100644 --- a/lib/foreman/cli.rb +++ b/lib/foreman/cli.rb @@ -15,6 +15,7 @@ class Foreman::CLI < Thor desc "start [PROCESS]", "Start the application (or a specific PROCESS)" + method_option :color, :type => :boolean, :aliases => "-c", :desc => "Force color to be enabled" method_option :env, :type => :string, :aliases => "-e", :desc => "Specify an environment file to load, defaults to .env" method_option :formation, :type => :string, :aliases => "-m", :banner => '"alpha=5,bar=3"' method_option :port, :type => :numeric, :aliases => "-p" @@ -83,11 +84,7 @@ class Foreman::CLI < Thor def engine @engine ||= begin engine_class = Foreman::Engine::CLI - engine = engine_class.new( - :formation => options[:formation], - :port => options[:port], - :root => options[:root] - ) + engine = engine_class.new(options) engine end end diff --git a/lib/foreman/engine/cli.rb b/lib/foreman/engine/cli.rb index 55f5cf8..6c44f43 100644 --- a/lib/foreman/engine/cli.rb +++ b/lib/foreman/engine/cli.rb @@ -24,11 +24,13 @@ class Foreman::Engine::CLI < Foreman::Engine :bright_white => 37, } - def self.enable(io) + def self.enable(io, force=false) io.extend(self) + @@color_force = force end def color? + return true if @@color_force return false unless self.respond_to?(:isatty) self.isatty && ENV["TERM"] end @@ -51,7 +53,7 @@ class Foreman::Engine::CLI < Foreman::Engine def output(name, data) data.to_s.chomp.split("\n").each do |message| - Color.enable($stdout) unless $stdout.respond_to?(:color?) + Color.enable($stdout, options[:color]) unless $stdout.respond_to?(:color?) output = "" output += $stdout.color(@colors[name.split(".").first].to_sym) output += "#{Time.now.strftime("%H:%M:%S")} #{pad_process_name(name)} | "