abstract class Athena::Console::Input
- Athena::Console::Input
- Reference
- Object
Overview
Common base implementation of ACON::Input::Interface
.
Included Modules
Direct Known Subclasses
Defined in:
completion/input.crinput/input.cr
Constructors
Instance Method Summary
-
#argument(name : String, type : T.class) : T forall T
Returns the value of the argument with the provided name converted to the desired 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 ofself
. -
#bind(definition : ACON::Input::Definition) : Nil
Binds the provided definition to
self
. -
#escape_token(token : String) : String
Escapes a token via Process.quote if it contains unsafe characters.
-
#has_argument?(name : String) : Bool
Returns
true
ifself
has an argument with the provided name, otherwisefalse
. -
#has_option?(name : String) : Bool
Returns
true
ifself
has an option with the provided name, otherwisefalse
. -
#interactive=(interactive : Bool)
Sets if
self
is#interactive?
. -
#interactive? : Bool
Returns
true
ifself
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.
-
#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 ofself
. -
#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.
-
#stream : IO | Nil
Returns the input stream.
-
#stream=(stream : IO | Nil)
Sets the input stream.
-
#validate : Nil
Validates the input, asserting all of the required parameters are provided.
Instance methods inherited from module Athena::Console::Input::Streamable
stream : IO | Nil
stream,
stream=(stream : IO | Nil)
stream=
Instance methods inherited from module Athena::Console::Input::Interface
argument(name : String, type : T.class) forall Targument(name : String) : String | Nil argument, arguments : ::Hash arguments, bind(definition : ACON::Input::Definition) : Nil bind, first_argument : String | Nil first_argument, has_argument?(name : String) : Bool has_argument?, has_option?(name : String) : Bool has_option?, has_parameter?(*values : String, only_params : Bool = false) : Bool has_parameter?, interactive=(interactive : Bool) interactive=, interactive? : Bool interactive?, option(name : String, type : T.class) forall T
option(name : String) : String | Nil option, options : ::Hash options, parameter(value : String, default : _ = false, only_params : Bool = false) parameter, set_argument(name : String, value : _) : Nil set_argument, set_option(name : String, value : _) : Nil set_option, to_s(io : IO) : Nil to_s, validate : Nil validate
Constructor Detail
Instance Method Detail
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.
Returns the raw string value of the argument with the provided name, or nil
if is optional and was not provided.
Returns a ::Hash
representing the keys and values of the parsed arguments of self
.
Binds the provided definition to self
.
Essentially provides what should be parsed from self
.
Escapes a token via Process.quote if it contains unsafe characters.
Returns true
if self
has an argument with the provided name, otherwise false
.
Returns true
if self
has an option with the provided name, otherwise false
.
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.
Returns the raw string value of the option with the provided name, or nil
if is optional and was not provided.
Returns a ::Hash
representing the keys and values of the parsed options of self
.
Sets the value of the argument with the provided name.
Sets the value of the option with the provided name.
Validates the input, asserting all of the required parameters are provided.
Raises ACON::Exceptions::ValidationFailed
if not valid.