Class: Miniflow::TTYCommand::CustomPretty

Inherits:
Printers::Pretty
  • Object
show all
Defined in:
lib/miniflow/tty_command.rb

Overview

TTY::Command custom printer

  • change default colors.

github.com/piotrmurach/tty-command#34-custom-printer

Instance Method Summary collapse

Instance Method Details



20
21
22
23
# File 'lib/miniflow/tty_command.rb', line 20

def print_command_err_data(cmd, *args)
  message = args.map(&:chomp).join(' ')
  write(cmd, "\t#{decorate(message, :white)}", err_data)
end


14
15
16
17
18
# File 'lib/miniflow/tty_command.rb', line 14

def print_command_start(cmd, *args)
  message = ["Running #{decorate(cmd.to_command, :cyan)}"]
  message << args.map(&:chomp).join(' ') unless args.empty?
  write(cmd, message.join)
end

#write(cmd, message, data = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/miniflow/tty_command.rb', line 25

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 = []
  out << "[#{decorate(cmd.uuid, :green)}] " if uuid_needed && !cmd.uuid.nil?
  out << "#{message}\n"
  target = cmd.only_output_on_error && !data.nil? ? data : output
  target << out.join
end