Methods |
abstract
protected
|
run(string ...$args): int|void
Run the command
Run the command
The command's return value will be:
- the return value of this method (if an
int is returned)
- the last value passed to {@see CliCommand::setExitStatus()}, or
-
0 , indicating success
Parameters
...$args |
Non-option arguments passed to the command.
|
Implemented by
|
#
|
protected
|
getOptionList(): iterable<CliOption|CliOptionBuilder>
Override to return a list of options for the command
Override to return a list of options for the command
Overriden by
|
#
|
protected
|
getLongDescription(): ?string
Override to return a detailed description of the command
Override to return a detailed description of the command
Overriden by
|
#
|
protected
|
getHelpSections(): array<CliHelpSectionName::*|string, string>
Override to return content for the command's help message
Override to return content for the command's help message
"NAME" , "SYNOPSIS" , "OPTIONS" and "DESCRIPTION" sections are
generated automatically and must not be returned by this method.
Returns
An array that maps
section names to content.
|
#
|
protected
|
filterJsonSchema(
array{$schema: string, type: string, required: string[], properties: array<string, mixed>} $schema,
): array{$schema: string, type: string, required: string[], properties: array<string, mixed>, ...}
Override to modify the command's JSON Schema before it is returned
Override to modify the command's JSON Schema before it is returned
|
#
|
protected
|
filterGetSchemaValues(mixed[] $values): mixed[]
Override to modify schema option values before they are returned
Override to modify schema option values before they are returned
|
#
|
protected
|
filterNormaliseSchemaValues(
array<array<string|int|bool|float>|string|int|bool|float|null> $values,
): array<array<string|int|bool|float>|string|int|bool|float|null>
Override to modify schema option values before they are normalised
Override to modify schema option values before they are normalised
|
#
|
protected
|
filterApplySchemaValues(
array<array<string|int|bool|float>|string|int|bool|float|null> $values,
bool $normalised,
): array<array<string|int|bool|float>|string|int|bool|float|null>
Override to modify schema option values before they are applied to the
command
Override to modify schema option values before they are applied to the
command
{@see filterNormaliseSchemaValues()} is always applied to $values
before {@see filterApplySchemaValues()}.
Parameters
$normalised |
true if $values have been normalised,
otherwise false .
|
|
#
|
public
|
__construct(CliApplicationInterface $app)
|
#
|
final
public
|
__invoke(string ...$args): int
Parse the given arguments and run the command
Parse the given arguments and run the command
Implements
|
#
|
final
public
|
getContainer(): CliApplicationInterface
Get the object's service container
Get the object's service container
Implements
|
#
|
final
public
|
getName(): string
Get the name of the object
Get the name of the object
Implements
|
#
|
final
public
|
getNameParts(): array
Get the command name as an array of subcommands
Get the command name as an array of subcommands
Implements
|
#
|
final
public
|
setName(array $name): void
Called immediately after instantiation by a CliApplicationInterface
Called immediately after instantiation by a CliApplicationInterface
Implements
|
#
|
final
public
|
getHelp(?CliHelpStyleInterface $style = null): array
Get a detailed explanation of the command
Get a detailed explanation of the command
Returns
An array that maps
help section names to content.
Implements
|
#
|
final
public
|
getSynopsis(?CliHelpStyleInterface $style = null): string
Get a one-line summary of the command's options
Get a one-line summary of the command's options
Returns a space-delimited string that includes the name of the command,
and the name used to run the script.
Implements
|
#
|
final
protected
|
getNameWithProgram(): string
Get the command name, including the name used to run the script, as a
string of space-delimited subcommands
Get the command name, including the name used to run the script, as a
string of space-delimited subcommands
|
#
|
final
public
|
getJsonSchema(): array{$schema: string, type: string, required?: string[], properties?: array<string, mixed>, ...}
Get the object's JSON Schema
Get the object's JSON Schema
Implements
|
#
|
final
protected
|
applyOptionValues(
array<array<string|int|bool|float>|string|int|bool|float|null> $values,
bool $normalise = true,
bool $expand = false,
bool $schema = false,
bool $asArguments = false,
bool $forgetArguments = false,
): mixed[]
Normalise an array of option values, apply them to the command, and
return them to the caller
Normalise an array of option values, apply them to the command, and
return them to the caller
Parameters
$normalise |
false if $values have already been normalised.
|
$expand |
If true and an option has an optional value, expand
null or true to the default value of the option. Ignored if
$normalise is false .
|
$schema |
If true , only apply $values to schema options.
|
$asArguments |
If true , apply $values as if they had been
given on the command line.
|
$forgetArguments |
If true and $asArguments is also true ,
apply $values as if any options previously given on the command line
had not been given.
|
|
#
|
final
protected
|
normaliseOptionValues(
array<array<string|int|bool|float>|string|int|bool|float|null> $values,
bool $expand = false,
bool $schema = false,
): mixed[]
Normalise an array of option values
Normalise an array of option values
Parameters
$expand |
If true and an option has an optional value, expand
null or true to the default value of the option.
|
$schema |
If true , only normalise schema options.
|
|
#
|
final
protected
|
checkOptionValues(mixed[] $values): bool
Check that an array of option values is valid
Check that an array of option values is valid
|
#
|
final
protected
|
getOptionValues(
bool $export = false,
bool $schema = false,
bool $unexpand = false,
): array<array<string|int|bool|float>|string|int|bool|float|null>
Get an array that maps option names to values
Get an array that maps option names to values
Parameters
$export |
If true , only options given on the command line are
returned.
|
$schema |
If true , an array that maps schema option names to
values is returned.
|
$unexpand |
If true and an option has an optional value not
given on the command line, replace its value with null or true .
|
|
#
|
final
protected
|
getDefaultOptionValues(bool $schema = false): array<array<string|int|bool|float>|string|int|bool|float|null>
Get an array that maps option names to default values
Get an array that maps option names to default values
Parameters
$schema |
If true , an array that maps schema option names to
default values is returned.
|
|
#
|
final
protected
|
getOptionValue(string $name): mixed
Get the value of a given option
Get the value of a given option
|
#
|
final
protected
|
optionHasArgument(string $name): bool
True if an option was given on the command line
True if an option was given on the command line
|
#
|
final
protected
|
getOption(string $name): CliOption
Get the given option
|
#
|
final
protected
|
hasOption(string $name): bool
True if the command has a given option
True if the command has a given option
|
#
|
final
protected
|
getOptions(): list<CliOption>
Get the command's options
Get the command's options
|
#
|
final
protected
|
isRunning(): bool
True if the command is currently running
True if the command is currently running
|
#
|
final
protected
|
setExitStatus(int $status): $this
Set the command's return value / exit status
Set the command's return value / exit status
|
#
|
final
protected
|
getExitStatus(): int
Get the current return value / exit status
Get the current return value / exit status
|
#
|
final
public
|
getRuns(): int
Get the number of times the command has run, including the current run
(if applicable)
Get the number of times the command has run, including the current run
(if applicable)
|
#
|