Skip to content

Commit e46d5d5

Browse files
committed
Add --no-color option
1 parent 7ce5567 commit e46d5d5

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

lib/foreman/cli.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ class Foreman::CLI < Foreman::Thor
1919

2020
desc "start [PROCESS]", "Start the application (or a specific PROCESS)"
2121

22-
method_option :color, :type => :boolean, :aliases => "-c", :desc => "Force color to be enabled"
23-
method_option :env, :type => :string, :aliases => "-e", :desc => "Specify an environment file to load, defaults to .env"
24-
method_option :formation, :type => :string, :aliases => "-m", :banner => '"alpha=5,bar=3"', :desc => 'Specify what processes will run and how many. Default: "all=1"'
25-
method_option :port, :type => :numeric, :aliases => "-p"
26-
method_option :timeout, :type => :numeric, :aliases => "-t", :desc => "Specify the amount of time (in seconds) processes have to shutdown gracefully before receiving a SIGKILL, defaults to 5."
27-
method_option :timestamp, :type => :boolean, :default => true, :desc => "Include timestamp in output"
22+
method_option :color, :type => :boolean, :aliases => "-c", :desc => "Force color to be enabled"
23+
method_option :"no-color", :type => :boolean, :default => false, :desc => "Force color to be disabled"
24+
method_option :env, :type => :string, :aliases => "-e", :desc => "Specify an environment file to load, defaults to .env"
25+
method_option :formation, :type => :string, :aliases => "-m", :banner => '"alpha=5,bar=3"', :desc => 'Specify what processes will run and how many. Default: "all=1"'
26+
method_option :port, :type => :numeric, :aliases => "-p"
27+
method_option :timeout, :type => :numeric, :aliases => "-t", :desc => "Specify the amount of time (in seconds) processes have to shutdown gracefully before receiving a SIGKILL, defaults to 5."
28+
method_option :timestamp, :type => :boolean, :default => true, :desc => "Include timestamp in output"
2829

2930
class << self
3031
# Hackery. Take the run method away from Thor so that we can redefine it.

lib/foreman/engine/cli.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ module Color
2424
:bright_white => 37,
2525
}
2626

27-
def self.enable(io, force=false)
27+
def self.enable(io, force=false, no_color=false)
2828
io.extend(self)
2929
@@color_force = force
30+
@@no_color = no_color
3031
end
3132

3233
def color?
3334
return true if @@color_force
35+
return false if @@no_color
3436
return false if Foreman.windows?
3537
return false unless self.respond_to?(:isatty)
3638
self.isatty && ENV["TERM"]
@@ -50,7 +52,7 @@ def color(name)
5052
def startup
5153
@colors = map_colors
5254
proctitle "foreman: master" unless Foreman.windows?
53-
Color.enable($stdout, options[:color])
55+
Color.enable($stdout, options[:color], options[:"no-color"])
5456
end
5557

5658
def output(name, data)

0 commit comments

Comments
 (0)