Exception: CLAide::Help
- Inherits:
-
StandardError
- Object
- StandardError
- CLAide::Help
- Includes:
- InformativeError
- Defined in:
- lib/claide/help.rb
Overview
The exception class that is raised to indicate a help banner should be shown while running Command.run.
Instance Attribute Summary collapse
-
#banner ⇒ String
readonly
command to show in the help.
-
#error_message ⇒ String
readonly
An optional error message that will be shown before the help banner.
Attributes included from InformativeError
Instance Method Summary collapse
-
#formatted_error_message ⇒ String
The optional error message, colored in red if Command.ansi_output is set to
true
. -
#initialize(banner, error_message = nil) ⇒ Help
constructor
A new instance of Help.
-
#message ⇒ String
The optional error message, combined with the help banner of the command.
- #prettify_error_message(message) ⇒ String
Constructor Details
#initialize(banner, error_message = nil) ⇒ Help
If an error message is provided, the exit status, used to
terminate the program with, will be set to 1
, otherwise a CLAide::Help
exception is treated as not being a real error and exits with 0
.
Returns a new instance of Help.
29 30 31 32 33 |
# File 'lib/claide/help.rb', line 29 def initialize(, = nil) @banner = @error_message = @exit_status = @error_message.nil? ? 0 : 1 end |
Instance Attribute Details
#banner ⇒ String (readonly)
command to show in the help.
15 16 17 |
# File 'lib/claide/help.rb', line 15 def @banner end |
#error_message ⇒ String (readonly)
Returns An optional error message that will be shown before the help banner.
20 21 22 |
# File 'lib/claide/help.rb', line 20 def @error_message end |
Instance Method Details
#formatted_error_message ⇒ String
Returns The optional error message, colored in red if
Command.ansi_output is set to true
.
38 39 40 41 42 43 |
# File 'lib/claide/help.rb', line 38 def if = "[!] #{}" () end end |
#message ⇒ String
Returns The optional error message, combined with the help banner of the command.
54 55 56 |
# File 'lib/claide/help.rb', line 54 def [, ].compact.join("\n\n") end |
#prettify_error_message(message) ⇒ String
47 48 49 |
# File 'lib/claide/help.rb', line 47 def () .ansi.red end |