abstract class Athena::Console::Input
inherits Reference
#
Common base implementation of ACON::Input::Interface.
Included modules
Athena::Console::Input::Streamable
Direct known subclasses
Athena::Console::Input::ARGV
Athena::Console::Input::Hash
Constructors#
Methods#
#argument(name : String, type : T.class) : T forall T#
Returns the value of the argument with the provided name converted to the desired type.
This method is preferred over #argument since it provides better typing.
Raises an ACON::Exception::Logic if the actual argument value could not be converted to a type.
#argument(name : String) : String | Nil#
Returns the raw string value of the argument with the provided name, or nil if is optional and was not provided.
#arguments : ::Hash#
Returns a ::Hash representing the keys and values of the parsed arguments of self.
#bind(definition : ACON::Input::Definition) : Nil#
Binds the provided definition to self.
Essentially provides what should be parsed from self.
#escape_token(token : String) : String#
Escapes a token via Process.quote if it contains unsafe characters.
#has_argument?(name : String) : Bool#
Returns true if self has an argument with the provided name, otherwise false.
#has_option?(name : String) : Bool#
Returns true if self has an option with the provided name, otherwise false.
#interactive? : Bool#
Returns true if self represents an interactive input, such as a TTY.
#option(name : String, type : T.class) : T forall T#
Returns the value of the option with the provided name converted to the desired type.
This method is preferred over #option since it provides better typing.
Raises an ACON::Exception::Logic if the actual option value could not be converted to a type.
#option(name : String) : String | Nil#
Returns the raw string value of the option with the provided name, or nil if is optional and was not provided.
#options : ::Hash#
Returns a ::Hash representing the keys and values of the parsed options of self.
#set_argument(name : String, value : _) : Nil#
Sets the value of the argument with the provided name.
#set_option(name : String, value : _) : Nil#
Sets the value of the option with the provided name.
#validate : Nil#
Validates the input, asserting all of the required parameters are provided.
Raises ACON::Exception::Runtime when not enough arguments are given.