Exception: GLI::MissingRequiredArgumentsException

Inherits:
BadCommandOptionsOrArguments show all
Defined in:
lib/gli/exceptions.rb

Instance Attribute Summary collapse

Attributes inherited from BadCommandOptionsOrArguments

#command_in_context

Instance Method Summary collapse

Methods inherited from BadCommandLine

#exit_code

Methods included from StandardException

#exit_code

Constructor Details

#initialize(command, num_arguments_received, range_arguments_accepted) ⇒ MissingRequiredArgumentsException

Returns a new instance of MissingRequiredArgumentsException.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/gli/exceptions.rb', line 73

def initialize(command,num_arguments_received,range_arguments_accepted)

  @num_arguments_received   = num_arguments_received
  @range_arguments_accepted = range_arguments_accepted

  message = if @num_arguments_received < @range_arguments_accepted.min
              "#{command.name} expected at least #{@range_arguments_accepted.min} arguments, but was given only #{@num_arguments_received}"
            elsif @range_arguments_accepted.min == 0
              "#{command.name} expected no arguments, but received #{@num_arguments_received}"
            else
              "#{command.name} expected only #{@range_arguments_accepted.max} arguments, but received #{@num_arguments_received}"
            end
  super(message,command)
end

Instance Attribute Details

#num_arguments_receivedObject (readonly)

Returns the value of attribute num_arguments_received.



72
73
74
# File 'lib/gli/exceptions.rb', line 72

def num_arguments_received
  @num_arguments_received
end

#range_arguments_acceptedObject (readonly)

Returns the value of attribute range_arguments_accepted.



72
73
74
# File 'lib/gli/exceptions.rb', line 72

def range_arguments_accepted
  @range_arguments_accepted
end