class Licensed::UI::Shell
Constants
- LEVELS
Public Class Methods
new()
click to toggle source
# File lib/licensed/ui/shell.rb, line 9 def initialize @shell = STDOUT.tty? ? Thor::Base.shell.new : Thor::Shell::Basic.new @level = ENV["DEBUG"] ? "debug" : "info" end
Public Instance Methods
confirm(msg, newline = true)
click to toggle source
# File lib/licensed/ui/shell.rb, line 22 def confirm(msg, newline = true) @shell.say msg, :green, newline if level?("confirm") end
debug(msg, newline = true)
click to toggle source
# File lib/licensed/ui/shell.rb, line 14 def debug(msg, newline = true) @shell.say msg, nil, newline if level?("debug") end
error(msg, newline = true)
click to toggle source
# File lib/licensed/ui/shell.rb, line 30 def error(msg, newline = true) @shell.say msg, :red, newline if level?("error") end
info(msg, newline = true)
click to toggle source
# File lib/licensed/ui/shell.rb, line 18 def info(msg, newline = true) @shell.say msg, nil, newline if level?("info") end
level=(level)
click to toggle source
# File lib/licensed/ui/shell.rb, line 38 def level=(level) raise ArgumentError unless LEVELS.include?(level.to_s) @level = level end
level?(name = nil)
click to toggle source
# File lib/licensed/ui/shell.rb, line 43 def level?(name = nil) name ? LEVELS.index(name) <= LEVELS.index(@level) : @level end
newline()
click to toggle source
# File lib/licensed/ui/shell.rb, line 34 def newline info "" end
silence() { || ... }
click to toggle source
# File lib/licensed/ui/shell.rb, line 47 def silence old_level, @level = @level, "silent" yield ensure @level = old_level end
warn(msg, newline = true)
click to toggle source
# File lib/licensed/ui/shell.rb, line 26 def warn(msg, newline = true) @shell.say msg, :yellow, newline if level?("warn") end