module Scripto::PrintCommands

Constants

GREEN
RED
RESET
YELLOW

Attributes

verbose[RW]

Public Instance Methods

banner(str, color: GREEN) click to toggle source

Print a colored banner to $stderr in green.

fatal(str) click to toggle source

Print a red error banner to $stderr, then exit.

# File lib/scripto/print_commands.rb, line 49
def fatal(str)
  banner(str, color: RED)
  exit(1)
end
vbanner(str = nil) click to toggle source

Print a colored banner to $stderr, but only if verbose?.

# File lib/scripto/print_commands.rb, line 22
def vbanner(str = nil)
  banner(str) if verbose?
end
verbose!() click to toggle source

Turn on verbose mode. vbanner, vputs and vprintf will start printing now, and file ops will be printed too.

# File lib/scripto/print_commands.rb, line 17
def verbose!
  @verbose = true
end
verbose?() click to toggle source

Is verbose mode turned on?

# File lib/scripto/print_commands.rb, line 11
def verbose?
  !!@verbose
end
vprintf(str, *args) click to toggle source

Printf to $stderr, but only if verbose?.

# File lib/scripto/print_commands.rb, line 32
def vprintf(str, *args)
  $stderr.printf(str, *args) if verbose?
end
vputs(str = nil) click to toggle source

Puts to $stderr, but only if verbose?.

# File lib/scripto/print_commands.rb, line 27
def vputs(str = nil)
  $stderr.puts(str) if verbose?
end
warning(str) click to toggle source

Print a yellow warning banner to $stderr.

# File lib/scripto/print_commands.rb, line 44
def warning(str)
  banner("Warning: #{str}", color: YELLOW)
end