Skip to content

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#

.new(definition : ACON::Input::Definition | Nil = nil)#

View source

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::Exceptions::Logic if the actual argument value could not be converted to a type.

View source

#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.

View source

#arguments : ::Hash#

Returns a ::Hash representing the keys and values of the parsed arguments of self.

View source

#bind(definition : ACON::Input::Definition) : Nil#

Binds the provided definition to self. Essentially provides what should be parsed from self.

View source

#escape_token(token : String) : String#

Escapes a token via Process.quote if it contains unsafe characters.

View source

#has_argument?(name : String) : Bool#

Returns true if self has an argument with the provided name, otherwise false.

View source

#has_option?(name : String) : Bool#

Returns true if self has an option with the provided name, otherwise false.

View source

#interactive=(interactive : Bool)#

Sets if self is #interactive?.

View source

#interactive? : Bool#

Returns true if self represents an interactive input, such as a TTY.

View source

#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::Exceptions::Logic if the actual option value could not be converted to a type.

View source

#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.

View source

#options : ::Hash#

Returns a ::Hash representing the keys and values of the parsed options of self.

View source

#set_argument(name : String, value : _) : Nil#

Sets the value of the argument with the provided name.

View source

#set_option(name : String, value : _) : Nil#

Sets the value of the option with the provided name.

View source

#stream : IO | ::Nil#

Returns the input stream.

View source

#stream=(stream : IO | Nil)#

Sets the input stream.

View source

#validate : Nil#

Validates the input, asserting all of the required parameters are provided. Raises ACON::Exceptions::ValidationFailed if not valid.

View source