Exception: Toys::ArgParser::ToolUnrecognizedError

Inherits:
UsageError
  • Object
show all
Defined in:
lib/toys/arg_parser.rb

Overview

A UsageError indicating the given subtool name does not exist.

Instance Attribute Summary collapse

Attributes inherited from UsageError

#message, #name, #suggestions, #value

Instance Method Summary collapse

Methods inherited from UsageError

#message_with_suggestions

Constructor Details

#initialize(message = nil, full_name: nil, suggestions: nil) ⇒ ToolUnrecognizedError

Create a ToolUnrecognizedError.

Parameters:

  • message (String, nil) (defaults to: nil)

    A custom message. Normally omitted, in which case an appropriate default is supplied.

  • full_name (Array<String>) (defaults to: nil)

    The full path of the requested tool. Normally required.

  • suggestions (Array<String>) (defaults to: nil)

    An array of suggestions to present to the user. Optional.



261
262
263
264
265
# File 'lib/toys/arg_parser.rb', line 261

def initialize(message = nil, full_name: nil, suggestions: nil)
  @full_name = Array(full_name)
  super(message || "Tool not found: \"#{@full_name.join(' ')}\"",
        value: @full_name.last, suggestions: suggestions, skip_frames: 1)
end

Instance Attribute Details

#full_nameArray<String> (readonly)

Returns The full name of the tool.

Returns:

  • (Array<String>)

    The full name of the tool



270
271
272
# File 'lib/toys/arg_parser.rb', line 270

def full_name
  @full_name
end