Skip to content

Internals Cli Commands HelloCommand

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

cli\commands\HelloCommand

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/cli/commands/HelloCommand.php · Snapshot 8411f4287706.

The CLI registers command objects and executes one command, then returns to a readline loop. Help and clear have special handling in the loop.

Imports and dependencies

use cli\interfaces\CLICommand;

HelloCommand

Declaration and architectural role

class HelloCommand implements CLICommand

Constants, enum cases, traits and properties

Declarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.

Member Declaration Purpose or source contract
$lastResult private string $lastResult = ''; Used by execute(), result().

Method index

Method Signature
getCommand public function getCommand(): string
getHelp public function getHelp(): string
getArguments public function getArguments(): array
execute public function execute(string $command, array $args = []): void
result public function result(): string

getCommand

Source line 15

public function getCommand(): string

Return expressions (including local callbacks): 'hello'.

Implementation, validation guards and interaction order
public function getCommand(): string
    {
        return 'hello';
    }

getHelp

Source line 21

public function getHelp(): string

Return expressions (including local callbacks): "hello [name]\nPrints 'Hello <name>' or 'Hello World' if name not given.".

Implementation, validation guards and interaction order
public function getHelp(): string
    {
        return "hello [name]\nPrints 'Hello <name>' or 'Hello World' if name not given.";
    }

getArguments

Source line 27

public function getArguments(): array

Return expressions (including local callbacks): ['name' => 'optional name to greet'].

Implementation, validation guards and interaction order
public function getArguments(): array
    {
        return ['name' => 'optional name to greet'];
    }

execute

Source line 33

public function execute(string $command, array $args = []): void

Parameters

Parameter Type, modifiers and default Purpose
$command string $command Operation input; the exact use, validation and propagation are shown in the implementation trace.
$args array $args = [] Ordered arguments passed to the command or method.

State writes: $this->lastResult.

Implementation, validation guards and interaction order
public function execute(string $command, array $args = []): void
    {
        $name = $args[0] ?? 'World';
        $this->lastResult = "Hello {$name}!";
    }

result

Source line 40

public function result(): string

Return expressions (including local callbacks): $this->lastResult.

Implementation, validation guards and interaction order
public function result(): string
    {
        return $this->lastResult;
    }

Related types

Clone this wiki locally