Input
Input
Console input parser and execution context holder.
class InputParses CLI argv tokens into module/command selection, global options, command-specific options, and positional arguments used during command execution.
Properties
executable
Executable basename used in usage/help messages.
private string $executableType: string
argv
private array $argvType: array
args
private array $argsType: array
globalOptions
private array $globalOptionsType: array
options
private array $optionsType: array
module
public string $moduleType: string
command
public string $commandType: string
commandObject
public Command $commandObjectType: Hazaar\Console\Command
Methods
initialise
Initialises the input object with the command line arguments.
public initialise(array $argv, array $moduleNames): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$argv | array | |
$moduleNames | array |
run
Binds a command definition and parses argv into option/argument values.
public run(Command $command, array $moduleOptions): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | Hazaar\Console\Command | command definition to parse against |
$moduleOptions | array | options defined at the module level |
getExecutable
public getExecutable(): stringReturns: string
getGlobalOption
public getGlobalOption(string $name): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string |
getModule
public getModule(): ?stringReturns: string
getCommandObject
public getCommandObject(): ?CommandReturns: Hazaar\Console\Command
getCommand
Gets the command that was used on the command line if it exists.
public getCommand(): ?stringReturns: string
getArgument
public getArgument(string $name): ?stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string |
getArguments
Gets all the arguments that were passed to the command.
public getArguments(): arrayReturns: array
getOption
public getOption(string $name, ?string $default): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | |
$default | string |
getOptions
Gets the options that were set on the command line.
public getOptions(): arrayReturns: array
setOption
public setOption(string $name, mixed $value): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | |
$value | mixed |
getArgv
Gets the options that were used on the command line.
public getArgv(): arrayReturns: array
readline
Displays a prompt and reads a line of input from STDIN.
public readline(string $prompt): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$prompt | string | the prompt to display to the user |
parseOption
Parses a command line option and adds it to the options array.
private parseOption(array $argv, array $optionsDefinition, array $options): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$argv | array | |
$optionsDefinition | array | |
$options | array |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:18 +0000