Class: Cuprum::Cli::Argument
- Parent Namespace
- Cuprum::Cli
- Inherited Classes
- Data
>
Object
- Defined In
- lib/cuprum/cli/argument.rb
Table Of Contents
Overview
Data object representing a positional command argument.
Back To Top
Constructor
#initialize(name:, default: nil, description: nil, parameter_name: nil, required: false, type: :string, variadic: false) => Argument
Parameters
- name (String, Symbol) — the name of the argument.
- default (Object, Proc) — the default value for the argument. If given
and the value of the argument is nil, sets the argument value to the
default value.
- description (String) — a short, human-readable description of the
argument.
- parameter_name (String) — a representation of the possible values for
the argument.
- required (true, false) — if true, raises an exception if the argument
is not provided to the command.
- type (Class, String, Symbol) — the expected type of the argument
value as a Class or class name. If given, raises an exception if the
argument value is not an instance of the type. Defaults to :string.
- variadic (true, false) — if true, the argument is variadic and
represents an array of arguments provided to the command. Defaults to
false.
Returns
- (Argument) — a new instance of Argument
Back To Top
Instance Attributes
#default => Object (readonly)
Returns the value of attribute default
Returns
- (Object) — the current value of default
#description => Object (readonly)
Returns the value of attribute description
Returns
- (Object) — the current value of description
#name => Object (readonly)
Returns the value of attribute name
Returns
- (Object) — the current value of name
#parameter_name => Object (readonly)
Returns the value of attribute parameter_name
Returns
- (Object) — the current value of parameter_name
#required => Object (readonly)
Also known as:
required?
Returns the value of attribute required
Returns
- (Object) — the current value of required
#type => Object (readonly)
Returns the value of attribute type
Returns
- (Object) — the current value of type
#variadic => Object (readonly)
Also known as:
variadic?
Returns the value of attribute variadic
Returns
- (Object) — the current value of variadic
Back To Top
Instance Methods
#resolve(value) => Object
Overloads
#resolve(value) => Object
Validates the value for the current argument.
If the value is nil, applies the argument default (if any).
Parameters
- value (Object) — the value to validate.
Returns
- (Object) — the validated argument value.
Raises
Raises
Back To Top
Back to
Documentation |
Reference
|
Cuprum
|
Cuprum::Cli