Skip to content

Commit

Permalink
add a really basic ui system
Browse files Browse the repository at this point in the history
  • Loading branch information
pearkes committed Aug 2, 2014
1 parent 6d0b88c commit 734a8b9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
53 changes: 53 additions & 0 deletions lib/tugboat/ui.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module Vagrant
module UI
# The basic UI interface provides output and
class Basic
# Colors for UI output
RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
GREY = "\033[37m"
CLEAR = "\033[0m"
PREFIX = " "

def init(machine=false)
@machine_readable = machine
end

# Outputs the message
#
# Possible output levels (lowest to highest) are:
# info: info statements that aren't important. gray coloring,
# indented ( )
# output: standard output (things are happening), no coloring,
# basic prefix (==>)
# success: successful actions, greeen, indented ( )
# warn: warnings, yellow, indented ( )
# fail: failures/danger, red, indented ( )
def say(message, level="output")
# If we've set machine-readable, don't color and
# merge the message into a line with commas instead of
# new lines.
if @machine_readable
message.gsub!("\n", ",") # Newlines to commas
message.gsub!(/\s/, ' ') # Make spaces/indents single
puts "#{Time.now.utc.to_i},#{message}"
return
end

case level
when "info"
puts "#{PREFIX} #{GREY}#{message}#{CLEAR}"
when "output"
puts "===> #{message}#{CLEAR}"
when "success"
puts "#{PREFIX} #{GREEN}#{message}#{CLEAR}"
when "warn"
puts "#{PREFIX} #{YELLOW}#{message}#{CLEAR}"
when "fail"
puts "#{PREFIX} #{RED}#{message}#{CLEAR}"
end
end
end
end
end
2 changes: 1 addition & 1 deletion tugboat.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
gem.required_ruby_version = ">= 1.9.2"

gem.add_dependency "thor", "~> 0.18.1"
gem.add_dependency "digital_ocean", "~> 1.0.1"
gem.add_dependency "barge", "~> 0.9.0"
gem.add_dependency "middleware" , "~> 0.1.0"

gem.add_development_dependency "rake"
Expand Down

0 comments on commit 734a8b9

Please sign in to comment.