class Athena::Console::CommandChain
inherits Reference
#
The commands resolved for the current invocation, from the root to the leaf, together with the input bound at each level.
Exposed via ACON::Application#command_chain while a command is running.
protected def execute(input : ACON::Input::Interface, output : ACON::Output::Interface) : ACON::Command::Status
# ./console docker --context=prod compose up
context = self.application.command_chain.try(&.input("docker")).try &.option("context") # => "prod"
ACON::Command::Status::SUCCESS
end
Implicit tree levels have no registered command and do not appear, except when the invocation ends on one: the running command is always the last level. See Sub-commands for more information.
Constructors#
Methods#
#command(name : String) : ACON::Command | Nil#
Returns the command of the level with the provided name, or nil if there is no such level.
#command(type : T.class) : T | Nil forall T#
Returns the command of the deepest level that is an instance of the provided type, or nil if there is no such level.
#commands : Array(ACON::Command)#
Returns the command of each level, from the root to the leaf.
#input(name : String) : ACON::Input::Interface | Nil#
Returns the input bound at the level of the command with the provided name, or nil if there is no such level.
The input of an ancestor level holds the options bound at that level; the running command has the input it was given, arguments included.
#input(type : T.class) : ACON::Input::Interface | Nil forall T#
Returns the input bound at the deepest level whose command is an instance of the provided type, or nil if there is no such level.
#inputs : Array(ACON::Input::Interface)#
Returns the input bound at each level, from the root to the leaf.