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

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

Returns the raw string value of the argument with the provided name, or nil if is optional and was not provided.

View source

#arguments #

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

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

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

Returns the raw string value of the option with the provided name, or nil if is optional and was not provided.

View source

#options #

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 #

Returns the input stream.

View source

#stream=(stream : IO?) #

Sets the input stream.

View source

#validate #

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

View source