class Athena::Console::Input::Definition
- Athena::Console::Input::Definition
- Reference
- Object
Overview
Represents a collection of ACON::Input::Arguments and ACON::Input::Options that are to be parsed from an ACON::Input::Interface.
Can be used to set the inputs of an ACON::Command via the ACON::Command#definition= method if so desired,
instead of using the dedicated methods.
Defined in:
input/definition.crConstructors
- .new(definition : ::Hash(String, ACON::Input::Option) | ::Hash(String, ACON::Input::Argument)) : self
- .new(definition : Array(ACON::Input::Argument | ACON::Input::Option) = Array(ACON::Input::Argument | ACON::Input::Option).new)
- .new(*definitions : ACON::Input::Argument | ACON::Input::Option) : self
Instance Method Summary
-
#<<(arguments : Array(ACON::Input::Argument | ACON::Input::Option)) : Nil
Adds the provided arguments to
self. -
#<<(argument : ACON::Input::Argument) : Nil
Adds the provided argument to
self. -
#<<(option : ACON::Input::Option) : Nil
Adds the provided options to
self. -
#argument(name_or_index : String | Int32) : ACON::Input::Argument
Returns the
ACON::Input::Argumentwith the provided name_or_index, otherwise raisesACON::Exception::InvalidArgumentif that argument is not defined. -
#argument_count : Int32
Returns the number of
ACON::Input::Arguments defined withinself. -
#argument_defaults : ::Hash
Returns a
::Hashwhose keys/values represent the names and default values of theACON::Input::Arguments defined withinself. - #arguments : ::Hash(String, ACON::Input::Argument)
-
#arguments=(arguments : Array(ACON::Input::Argument)) : Nil
Overrides the arguments of
selfto those in the provided arguments array. -
#definition=(definition : Array(ACON::Input::Argument | ACON::Input::Option)) : Nil
Overrides the arguments and options of
selfto those in the provided definition. -
#has_argument?(name_or_index : String | Int32) : Bool
Returns
trueifselfhas an argument with the provided name_or_index. -
#has_negation?(name : String | Char) : Bool
Returns
trueifselfhas a negation with the provided name, otherwisefalse. -
#has_option?(name_or_index : String | Int32) : Bool
Returns
trueifselfhas an option with the provided name_or_index. -
#has_shortcut?(name : String | Char) : Bool
Returns
trueifselfhas a shortcut with the provided name, otherwisefalse. -
#negation_to_name(negation : String) : String
Returns the name of the
ACON::Input::Optionthat maps to the provided negation. -
#option(name_or_index : String | Int32) : ACON::Input::Option
Returns the
ACON::Input::Optionwith the provided name_or_index, otherwise raisesACON::Exception::InvalidArgumentif that option is not defined. -
#option_defaults : ::Hash
Returns a
::Hashwhose keys/values represent the names and default values of theACON::Input::Options defined withinself. -
#option_for_shortcut(shortcut : String | Char) : ACON::Input::Option
Returns the name of the
ACON::Input::Optionwith the provided shortcut. - #options : ::Hash(String, ACON::Input::Option)
-
#options=(options : Array(ACON::Input::Option)) : Nil
Overrides the options of
selfto those in the provided options array. - #required_argument_count : Int32
-
#synopsis(short : Bool = false) : String
Returns an optionally short synopsis based on the
ACON::Input::Arguments andACON::Input::Options defined withinself.
Constructor Detail
Instance Method Detail
Adds the provided arguments to self.
Returns the ACON::Input::Argument with the provided name_or_index,
otherwise raises ACON::Exception::InvalidArgument if that argument is not defined.
Returns a ::Hash whose keys/values represent the names and default values of the ACON::Input::Arguments defined within self.
Overrides the arguments of self to those in the provided arguments array.
Overrides the arguments and options of self to those in the provided definition.
Returns true if self has an argument with the provided name_or_index.
Returns true if self has a negation with the provided name, otherwise false.
Returns true if self has an option with the provided name_or_index.
Returns true if self has a shortcut with the provided name, otherwise false.
Returns the name of the ACON::Input::Option that maps to the provided negation.
Returns the ACON::Input::Option with the provided name_or_index,
otherwise raises ACON::Exception::InvalidArgument if that option is not defined.
Returns a ::Hash whose keys/values represent the names and default values of the ACON::Input::Options defined within self.
Returns the name of the ACON::Input::Option with the provided shortcut.
Overrides the options of self to those in the provided options array.
Returns an optionally short synopsis based on the ACON::Input::Arguments and ACON::Input::Options defined within self.
The synopsis being the docopt string representing the expected options/arguments.
E.g. <name> move <x> <y> [--speed=<kn>].
ameba:disable Metrics/CyclomaticComplexity