Skip to content

class Athena::Console::Input::Definition
inherits Reference #

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.

Constructors#

.new(definition : ::Hash(String, ACON::Input::Option) | ::Hash(String, ACON::Input::Argument)) : self #

View source

.new(definition : Array(ACON::Input::Argument | ACON::Input::Option) = Array(ACON::Input::Argument | ACON::Input::Option).new) #

View source

.new(*definitions : ACON::Input::Argument | ACON::Input::Option) : self #

View source

Methods#

#<<(arguments : Array(ACON::Input::Argument | ACON::Input::Option)) : Nil #

Adds the provided arguments to self.

View source

#<<(argument : ACON::Input::Argument) : Nil #

Adds the provided argument to self.

View source

#<<(option : ACON::Input::Option) : Nil #

Adds the provided options to self.

View source

#argument(name_or_index : String | Int32) : ACON::Input::Argument #

Returns the ACON::Input::Argument with the provided name_or_index, otherwise raises ACON::Exceptions::InvalidArgument if that argument is not defined.

View source

#argument_count #

Returns the number of ACON::Input::Arguments defined within self.

View source

#argument_defaults #

Returns a ::Hash whose keys/values represent the names and default values of the ACON::Input::Arguments defined within self.

View source

#arguments #

View source

#arguments=(arguments : Array(ACON::Input::Argument)) : Nil #

Overrides the arguments of self to those in the provided arguments array.

View source

#definition=(definition : Array(ACON::Input::Argument | ACON::Input::Option)) : Nil #

Overrides the arguments and options of self to those in the provided definition.

View source

#has_argument?(name_or_index : String | Int32) : Bool #

Returns true if self has an argument with the provided name_or_index.

View source

#has_negation?(name : String | Char) : Bool #

Returns true if self has a negation with the provided name, otherwise false.

View source

#has_option?(name_or_index : String | Int32) : Bool #

Returns true if self has an option with the provided name_or_index.

View source

#has_shortcut?(name : String | Char) : Bool #

Returns true if self has a shortcut with the provided name, otherwise false.

View source

#negation_to_name(negation : String) : String #

Returns the name of the ACON::Input::Option that maps to the provided negation.

View source

#option(name_or_index : String | Int32) : ACON::Input::Option #

Returns the ACON::Input::Option with the provided name_or_index, otherwise raises ACON::Exceptions::InvalidArgument if that option is not defined.

View source

#option_defaults #

Returns a ::Hash whose keys/values represent the names and default values of the ACON::Input::Options defined within self.

View source

#option_for_shortcut(shortcut : String | Char) : ACON::Input::Option #

Returns the name of the ACON::Input::Option with the provided shortcut.

View source

#options #

View source

#options=(options : Array(ACON::Input::Option)) : Nil #

Overrides the options of self to those in the provided options array.

View source

#required_argument_count #

View source

#synopsis(short : Bool = false) : String #

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

View source