Command
Command
Console command definition and metadata container.
class CommandRepresents a single executable command with its callback target, argument definitions, option definitions, and descriptive metadata used by console help and command dispatch logic.
Properties
globalOptions
public array $globalOptionsapplication
Owning console application instance.
protected Application $applicationname
Command identifier used on the CLI.
private string $namedescription
Human-readable command description.
private string $descriptionoptions
private array $optionsarguments
private array $argumentscallback
Command callback target.
private mixed $callbackMethods
__construct
public __construct(string $name, array $callback): voidParameters
| Parameter | Type | Description |
|---|---|---|
$name | string | |
$callback | array |
getCallable
public getCallable(): voidgetName
Returns the command name.
public getName(): stringgetDescription
Returns the command description.
public getDescription(): stringgetOptions
public getOptions(): voidgetArguments
public getArguments(): voidsetName
Sets the command name.
public setName(string $name): selfParameters
| Parameter | Type | Description |
|---|---|---|
$name | string | command identifier |
setDescription
Sets the command description.
public setDescription(string $description): selfParameters
| Parameter | Type | Description |
|---|---|---|
$description | string | human-readable description text |
setHelp
Sets extended help text for the command.
public setHelp(string $help): selfThis method is currently a no-op and returns the command unchanged.
Parameters
| Parameter | Type | Description |
|---|---|---|
$help | string | extended help text |
addOption
Adds an option definition to the command.
public addOption(string $long, ?string $short, ?string $description, ?bool $takesValue, mixed $default, ?string $valueType): selfParameters
| Parameter | Type | Description |
|---|---|---|
$long | string | long option name without leading dashes |
$short | string | optional short option alias |
$description | string | optional option description |
$takesValue | bool | whether the option expects a value |
$default | mixed | default value used when omitted |
$valueType | string | optional expected value type |
addArgument
Adds a positional argument definition to the command.
public addArgument(string $name, ?string $description, bool $required): selfParameters
| Parameter | Type | Description |
|---|---|---|
$name | string | argument name |
$description | string | optional argument description |
$required | bool | whether the argument is required |
findOption
Finds an option by long or short name.
public findOption(string $name): ?OptionParameters
| Parameter | Type | Description |
|---|---|---|
$name | string | long or short option identifier |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000