Compare commits

...

4 Commits

Author SHA1 Message Date
David Dollar
9b704ad852 0.48.0.pre2 2012-06-17 22:02:14 -04:00
David Dollar
43428175c3 allow color to be forced on 2012-06-17 22:02:00 -04:00
David Dollar
87f65e489c terminate gracefully if stdout goes away 2012-06-17 21:55:28 -04:00
David Dollar
e5521f2cbb always flush output 2012-06-17 21:55:19 -04:00
4 changed files with 12 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
PATH
remote: .
specs:
foreman (0.48.0.pre1)
foreman (0.48.0.pre2)
thor (>= 0.13.6)
GEM
@@ -39,7 +39,7 @@ GEM
multi_json (~> 1.0.3)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
thor (0.14.6)
thor (0.15.2)
timecop (0.3.5)
win32console (1.3.0-x86-mingw32)
xml-simple (1.0.15)

View File

@@ -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

View File

@@ -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,14 +53,17 @@ 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)} | "
output += $stdout.color(:reset)
output += message
$stdout.puts output
$stdout.flush
end
rescue Errno::EPIPE
terminate_gracefully
end
def shutdown

View File

@@ -1,5 +1,5 @@
module Foreman
VERSION = "0.48.0.pre1"
VERSION = "0.48.0.pre2"
end