Class: TTY::Option::MissingParameter

Inherits:
ParseError show all
Defined in:
lib/tty/option/errors.rb

Overview

Raised when a parameter is required but not present

Constant Summary collapse

MESSAGE =
"%<type>s '%<name>s' must be provided"

Instance Attribute Summary

Attributes inherited from ParseError

#param

Instance Method Summary collapse

Methods inherited from ParseError

#format_value

Constructor Details

#initialize(param_or_message) ⇒ MissingParameter

Returns a new instance of MissingParameter.



127
128
129
130
131
132
133
134
135
136
# File 'lib/tty/option/errors.rb', line 127

def initialize(param_or_message)
  if param_or_message.is_a?(Parameter)
    @param = param_or_message
    message = format(MESSAGE, name: param.name, type: param.to_sym)
  else
    message = param_or_message
  end

  super(message)
end