Exception: Quickl::Help

Inherits:
Error show all
Defined in:
lib/quickl/errors.rb

Overview

This error can be raised to print command’s help and exit.

Default exit code:

0

Default reaction:

raise Exit.new(code), additional + "\n" + help, backtrace

Examples:

# Print command help on $stdout and exit with 0
raise Quickl::Help

# Print command help on $stderr and exit with -1
raise Quickl::Help.new(-1)

# Print additional message before help
raise Quickl::Help, "Hello user, below if the help!"

Instance Attribute Summary

Attributes inherited from Error

#command, #exit_code

Instance Method Summary collapse

Methods inherited from Error

#do_kernel_exit, #error_io, #exit?

Constructor Details

#initialize(*args) ⇒ Help

Returns a new instance of Help.



104
105
106
# File 'lib/quickl/errors.rb', line 104

def initialize(*args)
  super(*(args + [ 0 ]))
end

Instance Method Details

#react!Object

Raises:



108
109
110
111
112
113
114
115
# File 'lib/quickl/errors.rb', line 108

def react!
  msg = if (self.message || "").empty?
    command.class.help
  else
    self.message.to_s + "\n" + command.class.help
  end
  raise Exit.new(self.exit_code), msg, backtrace
end