class Rodish::CommandFailure

  1. lib/rodish/errors.rb
Superclass: CommandExit

Rodish::CommandFailure is used for failures of commands, such as:

  • Invalid options

  • Invalid number of arguments for a command

  • Invalid subcommands

  • No subcommand given for a command that only supports subcommands

Methods

Public Class

  1. new

Public Instance

  1. command
  2. failure?
  3. message_with_usage

Attributes

command [R]

Public Class methods

new(message, command=nil)
[show source]
   # File lib/rodish/errors.rb
31 def initialize(message, command=nil)
32   @command = command
33   super(message)
34 end

Public Instance methods

failure?()

Always returns false, since CommandFailure represents failures.

[show source]
   # File lib/rodish/errors.rb
37 def failure?
38   true
39 end
message_with_usage()

Return the message along with the content of any related option parsers. This can be used to show usage an options along with error messages for failing commands.

[show source]
   # File lib/rodish/errors.rb
44 def message_with_usage
45   help = @command&.help || ''
46   if help.empty?
47     message
48   else
49     "#{message}\n\n#{help}"
50   end
51 end