class TTY::Command::Printers::Pretty

Constants

TIME_FORMAT

Public Class Methods

new(*) click to toggle source
Calls superclass method TTY::Command::Printers::Abstract::new
# File lib/tty/command/printers/pretty.rb, line 9
def initialize(*)
  super
  @uuid = options.fetch(:uuid, true)
end

Public Instance Methods

print_command_err_data(cmd, *args) click to toggle source
print_command_exit(cmd, status, runtime, *args) click to toggle source
print_command_out_data(cmd, *args) click to toggle source
print_command_start(cmd, *args) click to toggle source
write(cmd, message, data = nil) click to toggle source

Write message out to output

@api private

# File lib/tty/command/printers/pretty.rb, line 46
def write(cmd, message, data = nil)
  cmd_set_uuid = cmd.options.fetch(:uuid, true)
  uuid_needed = cmd.options[:uuid].nil? ? @uuid : cmd_set_uuid
  out = []
  if uuid_needed
    out << "[#{decorate(cmd.uuid, :green)}] " unless cmd.uuid.nil?
  end
  out << "#{message}\n"
  target = (cmd.only_output_on_error && !data.nil?) ? data : output
  target << out.join
end

Private Instance Methods

pluralize(count, word) click to toggle source

Pluralize word based on a count

@api private

# File lib/tty/command/printers/pretty.rb, line 63
def pluralize(count, word)
  "#{word}#{'s' unless count.to_i == 1}"
end
success_or_failure(status) click to toggle source

@api private

# File lib/tty/command/printers/pretty.rb, line 68
def success_or_failure(status)
  if status == 0
    decorate("successful", :green, :bold)
  else
    decorate("failed", :red, :bold)
  end
end