abstract class Athena::Console::Input

Overview

Common base implementation of ACON::Input::Interface.

Included Modules

Direct Known Subclasses

Defined in:

completion/input.cr
input/input.cr

Constructors

Instance Method Summary

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 T
argument(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

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

[View source]

Instance Method Detail

def 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]
def 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]
def arguments : ::Hash #

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


[View source]
def bind(definition : ACON::Input::Definition) : Nil #

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


[View source]
def escape_token(token : String) : String #

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


[View source]
def has_argument?(name : String) : Bool #

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


[View source]
def has_option?(name : String) : Bool #

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


[View source]
def interactive=(interactive : Bool) #

Sets if self is #interactive?.


[View source]
def interactive? : Bool #

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


[View source]
def 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]
def 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]
def options : ::Hash #

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


[View source]
def set_argument(name : String, value : _) : Nil #

Sets the value of the argument with the provided name.


[View source]
def set_option(name : String, value : _) : Nil #

Sets the value of the option with the provided name.


[View source]
def stream : IO | Nil #

Returns the input stream.


[View source]
def stream=(stream : IO | Nil) #

Sets the input stream.


[View source]
def validate : Nil #

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


[View source]