class

Athena::Console::Input::Argument

Inherits Reference / Object

Represents a value (or array of values) provided to a command as a ordered positional argument, that can either be required or optional, optionally with a default value and/or description.

Arguments are strings separated by spaces that come after the command name. For example, ./console test arg1 "Arg2 with spaces".

Arguments can be added via the ACON::Command#argument method, or by instantiating one manually as part of an ACON::Input::Definition. The value of the argument could then be accessed via one of the ACON::Input::Interface#argument overloads.

See ACON::Input::Interface for more examples on how arguments/options are parsed, and how they can be accessed.

Constructors

new(name : String, mode : ACON::Input::Argument::Mode = :optional, description : String = "", default = nil, suggested_values : Array(String) | Proc(ACON::Completion::Input, Array(String)) | Nil = nil)
Source

Instance methods

complete(input : ACON::Completion::Input, suggestions : ACON::Completion::Suggestions) : Nil

Determines what values should be added to the possible suggestions based on the provided input.

Source
default(type : T.class) : T forall T

Returns the default value of self, if any, converted to the provided type.

Source
default

Returns the default value of self, if any.

Source
default=(default = nil)

Sets the default value of self.

Source
description

Returns the description of self.

Source
has_completion?

Returns true if this argument is able to suggest values, otherwise false

Source
is_array?

Returns true if self expects an array of values, otherwise false. ameba:disable Naming/PredicateName

Source
mode

Returns the ACON::Input::Argument::Mode of self.

Source
name

Returns the name of the self.

Source
required?

Returns true if self is a required argument, otherwise false.

Source

Nested types