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 $globalOptionsType: array
application
Owning console application instance.
protected Application $applicationType: Hazaar\Console\Application
name
Command identifier used on the CLI.
private string $nameType: string
description
Human-readable command description.
private string $descriptionType: string
options
private array $optionsType: array
arguments
private array $argumentsType: array
callback
Command callback target.
private array $callbackType: array
Methods
__construct
public __construct(string $name, array $callback): voidParameters
| Parameter | Type | Description |
|---|---|---|
$name | string | |
$callback | array |
getCallable
public getCallable(): arrayReturns: array
getName
Returns the command name.
public getName(): stringReturns: string
getDescription
Returns the command description.
public getDescription(): stringReturns: string
getOptions
public getOptions(): arrayReturns: array
getArguments
public getArguments(): arrayReturns: array
setName
Sets the command name.
public setName(string $name): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | command identifier |
setDescription
Sets the command description.
public setDescription(string $description): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$description | string | human-readable description text |
setHelp
Sets extended help text for the command.
public setHelp(string $help): selfReturns: self
This 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): selfReturns: self
Parameters
| 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): selfReturns: self
Parameters
| 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): ?OptionReturns: Hazaar\Console\Option
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | long or short option identifier |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:18 +0000