class CLAide::Help
The exception class that is raised to indicate a help banner should be shown while running {Command.run}.
Attributes
error_message[R]
@return [String] An optional error message that will be shown before the
help banner.
Public Class Methods
new(banner, error_message = nil)
click to toggle source
@param [String] banner @see banner @param [String] error_message
@see error_message
@note If an error message is provided, the exit status, used to
terminate the program with, will be set to `1`, otherwise a {Help} exception is treated as not being a real error and exits with `0`.
# File lib/claide/help.rb, line 29 def initialize(banner, error_message = nil) @banner = banner @error_message = error_message @exit_status = @error_message.nil? ? 0 : 1 end
Public Instance Methods
formatted_error_message()
click to toggle source
@return [String] The optional error message, colored in red if
{Command.ansi_output} is set to `true`.
# File lib/claide/help.rb, line 38 def formatted_error_message if error_message message = "[!] #{error_message}" prettify_error_message(message) end end
message()
click to toggle source
@return [String] The optional error message, combined with the help
banner of the command.
# File lib/claide/help.rb, line 54 def message [formatted_error_message, banner].compact.join("\n\n") end
prettify_error_message(message)
click to toggle source
@return [String]
# File lib/claide/help.rb, line 47 def prettify_error_message(message) message.ansi.red end