Module: CommandKit::Printing

Includes:
Stdio
Included in:
Command, ExceptionHandler, Options::Parser
Defined in:
lib/command_kit/printing.rb,
lib/command_kit/printing/indent.rb

Overview

Provides printing methods.

Defined Under Namespace

Modules: Indent

Constant Summary collapse

EOL =

Platform independency new-line constant

Returns:

  • (String)
$/

Instance Method Summary collapse

Methods included from Stdio

#abort, #gets, #initialize, #print, #printf, #putc, #puts, #readline, #readlines, #stderr, #stdin, #stdout

Instance Method Details

Prints the error message to stderr.

Examples:

print_error "Error: invalid input"

Parameters:

  • message (String)

    The error message.



30
31
32
# File 'lib/command_kit/printing.rb', line 30

def print_error(message)
  stderr.puts message
end

Prints an exception to stderr.

Examples:

begin
  # ...
rescue => error
  print_error "Error encountered"
  print_exception(error)
  exit(1)
end

Parameters:

  • error (Exception)

    The error to print.



51
52
53
# File 'lib/command_kit/printing.rb', line 51

def print_exception(error)
  print_error error.full_message(highlight: stderr.tty?)
end