class Geny::Actions::UI

Utillities for printing to the console. @see rubydoc.info/github/piotrmurach/tty-prompt/TTY/Prompt TTY::Prompt

Attributes

color[R]

Public Class Methods

new(color:, **opts) click to toggle source

Create a new UI @param color [Pastel]

Calls superclass method
# File lib/geny/actions/ui.rb, line 12
def initialize(color:, **opts)
  super(**opts)
  @color = color
end

Public Instance Methods

abort!(message) click to toggle source

Print and error and abort @param message [String] @raise [SystemExit]

@example

ui.abort! "command failed, exiting"
# File lib/geny/actions/ui.rb, line 53
def abort!(message)
  error(message)
  exit 1
end
error(message) click to toggle source

Print an error @param message [String]

@example

ui.error "the world is ending"
# File lib/geny/actions/ui.rb, line 43
def error(message)
  stderr.puts "#{@color.red("ERROR:")} #{message}"
end
heading(message) click to toggle source

Print a heading @param message [String]

@example

ui.heading "Files"
# File lib/geny/actions/ui.rb, line 22
def heading(message)
  say "#{@color.dim("==")} #{@color.bold(message)}"
end
status(label, message, color: :green) click to toggle source

Print a status @param label [String] @param message [String] @param color [Symbol]

@example

ui.status "create", "hello.txt"
ui.status "remove", "hello.txt", color: :red
# File lib/geny/actions/ui.rb, line 34
def status(label, message, color: :green)
  say "#{@color.send(color, label.rjust(12))}  #{message}"
end