class Athena::Console::Input::Option

Overview

Represents a value (or array of ) provided to a command as optional un-ordered flags that be setup to accept a value, or represent a boolean flag. Options can also have an optional shortcut, default value, and/or description.

Options are specified with two dashes, or one dash when using the shortcut. For example, ./console test --yell --dir=src -v. We have one option representing a boolean value, providing a value to another, and using the shortcut of another.

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

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

Defined in:

input/option.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String, shortcut : String | Enumerable(String) | Nil = nil, value_mode : ACON::Input::Option::Value = :none, description : String = "", default = nil, suggested_values : Array(String) | Proc(ACON::Completion::Input, Array(String)) | Nil = nil) #

[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


[View source]
def accepts_value? : Bool #

Returns true if self is able to accept a value, otherwise false.


[View source]
def 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.


[View source]
def default(type : T.class) : T forall T #

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


[View source]
def default #

Returns the default value of self, if any.


[View source]
def default=(default = nil) : Nil #

Sets the default value of self.


[View source]
def description : String #

Returns the description of self.


[View source]
def has_completion? : Bool #

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


[View source]
def is_array? : Bool #

Returns true if self is a required argument, otherwise false. ameba:disable Naming/PredicateName


[View source]
def name : String #

Returns the name of self.


[View source]
def negatable? : Bool #

Returns true if self is negatable, otherwise false.


[View source]
def shortcut : String | Nil #

Returns the shortcut of self, if any.


[View source]
def value_mode : ACON::Input::Option::Value #

Returns the ACON::Input::Option::Value of self.


[View source]
def value_optional? : Bool #

Returns true if self accepts a value but is optional, otherwise false.


[View source]
def value_required? : Bool #

Returns true if self accepts a value and it is required, otherwise false.


[View source]