HelpCommand
extends BaseCommand
in package
implements
CommandCollectionAwareInterface
Print out command list
Table of Contents
Interfaces
- CommandCollectionAwareInterface
- An interface for shells that take a CommandCollection during initialization.
Properties
- $commands : CommandCollection
- The command collection to get help on.
- $name : string
- The name of this command.
Methods
- abort() : void
- Halt the the current process with a StopException.
- defaultName() : string
- Get the command name.
- execute() : int
- Main function Prints out the list of commands.
- executeCommand() : int|null
- Execute another command with the provided set of arguments.
- getDescription() : string
- Get the command description.
- getName() : string
- Get the command name.
- getOptionParser() : ConsoleOptionParser
- Get the option parser.
- getRootName() : string
- Get the root command name.
- initialize() : void
- Hook method invoked by CakePHP when a command is about to be executed.
- run() : int|null
- Run the command.
- setCommandCollection() : void
- Set the command collection being used.
- setName() : $this
- Set the name this command uses in the collection.
- asText() : void
- Output text.
- asXml() : void
- Output as XML
- buildOptionParser() : ConsoleOptionParser
- Gets the option parser instance and configures it.
- displayHelp() : void
- Output help content
- getShortestName() : string
- outputPaths() : void
- Output relevant paths if defined
- setOutputLevel() : void
- Set the output level based on the Arguments.
Properties
$commands
The command collection to get help on.
protected
CommandCollection
$commands
$name
The name of this command.
protected
string
$name
= 'cake unknown'
Methods
abort()
Halt the the current process with a StopException.
public
abort([int $code = self::CODE_ERROR ]) : void
Parameters
- $code : int = self::CODE_ERROR
-
The exit code to use.
Tags
defaultName()
Get the command name.
public
static defaultName() : string
Returns the command name based on class name.
For e.g. for a command with class name UpdateTableCommand
the default
name returned would be 'update_table'
.
Return values
stringexecute()
Main function Prints out the list of commands.
public
execute(Arguments $args, ConsoleIo $io) : int
Parameters
Return values
intexecuteCommand()
Execute another command with the provided set of arguments.
public
executeCommand(CommandInterface|string $command[, array<string|int, mixed> $args = [] ][, ConsoleIo|null $io = null ]) : int|null
If you are using a string command name, that command's dependencies will not be resolved with the application container. Instead you will need to pass the command as an object with all of its dependencies.
Parameters
- $command : CommandInterface|string
-
The command class name or command instance.
- $args : array<string|int, mixed> = []
-
The arguments to invoke the command with.
- $io : ConsoleIo|null = null
-
The ConsoleIo instance to use for the executed command.
Return values
int|null —The exit code or null for success of the command.
getDescription()
Get the command description.
public
static getDescription() : string
Return values
stringgetName()
Get the command name.
public
getName() : string
Return values
stringgetOptionParser()
Get the option parser.
public
getOptionParser() : ConsoleOptionParser
You can override buildOptionParser() to define your options & arguments.
Tags
Return values
ConsoleOptionParsergetRootName()
Get the root command name.
public
getRootName() : string
Return values
stringinitialize()
Hook method invoked by CakePHP when a command is about to be executed.
public
initialize() : void
Override this method and implement expensive/important setup steps that should not run on every command run. This method will be called before the options and arguments are validated and processed.
run()
Run the command.
public
run(array<string|int, mixed> $argv, ConsoleIo $io) : int|null
Parameters
- $argv : array<string|int, mixed>
-
Arguments from the CLI environment.
- $io : ConsoleIo
-
The console io
Tags
Return values
int|null —Exit code or null for success.
setCommandCollection()
Set the command collection being used.
public
setCommandCollection(CommandCollection $commands) : void
Parameters
- $commands : CommandCollection
-
The commands to use.
Tags
setName()
Set the name this command uses in the collection.
public
setName(string $name) : $this
Parameters
- $name : string
-
The name the command uses in the collection.
Tags
Return values
$thisasText()
Output text.
protected
asText(ConsoleIo $io, iterable<string|int, mixed> $commands) : void
Parameters
- $io : ConsoleIo
-
The console io
- $commands : iterable<string|int, mixed>
-
The command collection to output.
asXml()
Output as XML
protected
asXml(ConsoleIo $io, iterable<string|int, mixed> $commands) : void
Parameters
- $io : ConsoleIo
-
The console io
- $commands : iterable<string|int, mixed>
-
The command collection to output
buildOptionParser()
Gets the option parser instance and configures it.
protected
buildOptionParser(ConsoleOptionParser $parser) : ConsoleOptionParser
Parameters
- $parser : ConsoleOptionParser
-
The parser to build
Return values
ConsoleOptionParserdisplayHelp()
Output help content
protected
displayHelp(ConsoleOptionParser $parser, Arguments $args, ConsoleIo $io) : void
Parameters
- $parser : ConsoleOptionParser
-
The option parser.
- $args : Arguments
-
The command arguments.
- $io : ConsoleIo
-
The console io
getShortestName()
protected
getShortestName(array<string|int, string> $names) : string
Parameters
- $names : array<string|int, string>
-
Names
Return values
stringoutputPaths()
Output relevant paths if defined
protected
outputPaths(ConsoleIo $io) : void
Parameters
- $io : ConsoleIo
-
IO object.
setOutputLevel()
Set the output level based on the Arguments.
protected
setOutputLevel(Arguments $args, ConsoleIo $io) : void