class

Command::Base

Inherits Reference < Object

Base class for creating command-line interfaces.

Constructors

new(args : Array(Argument), root : Command::Base | Nil = nil, name : String | Nil = nil)
Source

Class methods

description(text : String)
Source
for(args, root)
Source
get_command(cmd_array)
Source
option(long : String, short : String, description : String = "", default : String | Nil = nil, required : Bool = false, type : Symbol = :bool)

Defines a command-line option.

Source
positional(name : String, description : String = "", type : Symbol = :string, required : Bool = true)

Defines a positional argument.

Source
self_description
Source
self_description=(self_description : String | Nil)
Source
self_options
Source
self_options=(self_options : Hash(String, NamedTuple(short: String, description: String, default: Nil | String, required: Bool, type: Symbol)))
Source
self_positionals
Source
self_positionals=(self_positionals : Array(NamedTuple(name: String, description: String, type: Symbol, required: Bool)))
Source
self_sub_commands
Source
self_sub_commands=(self_sub_commands : Hash(String, ::Command::Base.class))
Source
sub_command(name : String, command : Command::Base.class)

Defines a subcommand.

Source

Instance methods

error!(message)
Source
option(name : String) : String | Nil

Gets the value of a parsed option.

Source
parent(t : T.class = Command::Base) forall T

Access the parent command.

Source
positional

Gets the array of parsed positional arguments.

Source
process(args : Array(Argument))

Processes the parsed arguments.

Source
root(t : T.class = Command::Root) forall T

Access the root command.

Source
run

Executes the command.

Source
run_impl

The implementation logic for the command.

Source
sub_command_instance
Source