An interface for shells that take a CommandCollection during initialization.
An interface for abstracting creation of command and shell instances.
Provides an interface for interacting with a command's options and arguments.
Base class for console commands.
Collection for Commands.
Used by Applications to whitelist their console commands. CakePHP will use the mapped commands to construct and dispatch shell commands.
This is a factory for creating Command and Shell instances.
This factory can be replaced or extended if you need to customize building your command and shell objects.
Run CLI commands for the provided application.
Used by CommandCollection and CommandTask to scan the filesystem for command classes.
Error Handler for Cake console. Does simple printing of the exception that occurred and the stack trace of the error.
Object wrapper for interacting with stdin
An object to represent a single argument used in the command line. ConsoleOptionParser creates these when you use addArgument()
An object to represent a single option used in the command line. ConsoleOptionParser creates these when you use addOption()
An object to represent a single subcommand used in the command line. Created when you call ConsoleOptionParser::addSubcommand()
A wrapper around the various IO operations shell tasks need to do.
Packages up the stdout, stderr, and stdin streams providing a simple consistent interface for shells to use. This class also makes mocking streams easy to do in unit tests.
Handles parsing the ARGV in the command line and provides support for GetOpt compatible option definition. Provides a builder pattern implementation for creating shell option parsers.
Named arguments come in two forms, long and short. Long arguments are preceded
by two - and give a more verbose option name. i.e. --version. Short arguments are
preceded by one - and are only one character long. They usually match with a long option,
and provide a more terse alternative.
Options can be defined with both long and short forms. By using $parser->addOption()
you can define new options. The name of the option is used as its long form, and you
can supply an additional short form, with the short option. Short options should
only be one letter long. Using more than one letter for a short option will raise an exception.
Calling options can be done using syntax similar to most *nix command line tools. Long options
cane either include an = or leave it out.
cake myshell command --connection default --name=something
Short options can be defined singly or in groups.
cake myshell command -cn
Short options can be combined into groups as seen above. Each letter in a group will be treated as a separate option. The previous example is equivalent to:
cake myshell command -c -n
Short options can also accept values:
cake myshell command -c default
If no positional arguments are defined, all of them will be parsed. If you define positional arguments any arguments greater than those defined will cause exceptions. Additionally you can declare arguments as optional, by setting the required param to false.
$parser->addArgument('model', ['required' => false]);
By providing help text for your positional arguments and named arguments, the ConsoleOptionParser
can generate a help display for you. You can view the help for shells by using the --help or -h switch.
Object wrapper for outputting information from a shell application. Can be connected to any stream resource that can be used with fopen()
Can generate colorized output on consoles that support it. There are a few built in styles
error Error messages.warning Warning messages.info Informational messages.comment Additional text.question Magenta text used for user promptsBy defining styles with addStyle() you can create custom console styles.
You can format console output using tags with the name of the style to apply. From inside a shell object
$this->out('<warning>Overwrite:</warning> foo.php was overwritten.');
This would create orange 'Overwrite:' text, while the rest of the text would remain the normal color. See ConsoleOutput::styles() to learn more about defining your own styles. Nested styles are not supported at this time.
HelpFormatter formats help for console shells. Can format to either text or XML formats. Uses ConsoleOptionParser methods to generate help.
Generally not directly used. Using $parser->help($command, 'xml'); is usually
how you would access help. Or via the --help=xml option on the command line.
Xml output is useful for integration with other tools like IDE's or other build tools.
Base class for Helpers.
Console Helpers allow you to package up reusable blocks of Console output logic. For example creating tables, progress bars or ascii art.
Registry for Helpers. Provides features for lazily loading helpers.
Base class for command-line utilities for automating programmer chores.
Is the equivalent of Cake\Controller\Controller on the command line.
Shell dispatcher handles dispatching cli commands.
Consult /bin/cake.php for how this class is used in practice.
Registry for Tasks. Provides features for lazily loading tasks.