VERBOSE
VERBOSE = 2 : integer
Output constant making verbose shells.
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.
$_out : \Cake\Console\ConsoleOutput
The output stream
$_err : \Cake\Console\ConsoleOutput
The error stream
$_in : \Cake\Console\ConsoleInput
The input stream
$_helpers : \Cake\Console\HelperRegistry
The helper registry.
__construct(\Cake\Console\ConsoleOutput|null $out = null, \Cake\Console\ConsoleOutput|null $err = null, \Cake\Console\ConsoleInput|null $in = null, \Cake\Console\HelperRegistry|null $helpers = null)
Constructor
\Cake\Console\ConsoleOutput|null | $out | A ConsoleOutput object for stdout. |
\Cake\Console\ConsoleOutput|null | $err | A ConsoleOutput object for stderr. |
\Cake\Console\ConsoleInput|null | $in | A ConsoleInput object for stdin. |
\Cake\Console\HelperRegistry|null | $helpers | A HelperRegistry instance |
verbose(string|array $message, integer $newlines = 1) : integer|boolean
Output at the verbose level.
string|array | $message | A string or an array of strings to output |
integer | $newlines | Number of newlines to append |
The number of bytes returned from writing to stdout.
quiet(string|array $message, integer $newlines = 1) : integer|boolean
Output at all levels.
string|array | $message | A string or an array of strings to output |
integer | $newlines | Number of newlines to append |
The number of bytes returned from writing to stdout.
out(string|array $message = '', integer $newlines = 1, integer $level = self::NORMAL) : integer|boolean
Outputs a single or multiple messages to stdout. If no parameters are passed outputs just a newline.
There are 3 built-in output level. ConsoleIo::QUIET, ConsoleIo::NORMAL, ConsoleIo::VERBOSE.
The verbose and quiet output levels, map to the verbose
and quiet
output switches
present in most shells. Using ConsoleIo::QUIET for a message means it will always display.
While using ConsoleIo::VERBOSE means it will only display when verbose output is toggled.
string|array | $message | A string or an array of strings to output |
integer | $newlines | Number of newlines to append |
integer | $level | The message's output level, see above. |
The number of bytes returned from writing to stdout.
info(string|array|null $message = null, integer $newlines = 1, integer $level = self::NORMAL) : integer|boolean
Convenience method for out() that wraps message between <info /> tag
string|array|null | $message | A string or an array of strings to output |
integer | $newlines | Number of newlines to append |
integer | $level | The message's output level, see above. |
The number of bytes returned from writing to stdout.
warning(string|array|null $message = null, integer $newlines = 1) : integer|boolean
Convenience method for err() that wraps message between <warning /> tag
string|array|null | $message | A string or an array of strings to output |
integer | $newlines | Number of newlines to append |
The number of bytes returned from writing to stderr.
error(string|array|null $message = null, integer $newlines = 1) : integer|boolean
Convenience method for err() that wraps message between <error /> tag
string|array|null | $message | A string or an array of strings to output |
integer | $newlines | Number of newlines to append |
The number of bytes returned from writing to stderr.
success(string|array|null $message = null, integer $newlines = 1, integer $level = self::NORMAL) : integer|boolean
Convenience method for out() that wraps message between <success /> tag
string|array|null | $message | A string or an array of strings to output |
integer | $newlines | Number of newlines to append |
integer | $level | The message's output level, see above. |
The number of bytes returned from writing to stdout.
overwrite(array|string $message, integer $newlines = 1, integer|null $size = null) : void
Overwrite some already output text.
Useful for building progress bars, or when you want to replace text already output to the screen with new text.
Warning You cannot overwrite text that contains newlines.
array|string | $message | The message to output. |
integer | $newlines | Number of newlines to append. |
integer|null | $size | The number of bytes to overwrite. Defaults to the length of the last message output. |
err(string|array $message = '', integer $newlines = 1) : integer|boolean
Outputs a single or multiple error messages to stderr. If no parameters are passed outputs just a newline.
string|array | $message | A string or an array of strings to output |
integer | $newlines | Number of newlines to append |
The number of bytes returned from writing to stderr.
styles(string|null $style = null, array|boolean|null $definition = null) : mixed
Add a new output style or get defined styles.
string|null | $style | The style to get or create. |
array|boolean|null | $definition | The array definition of the style to change or create a style or false to remove a style. |
If you are getting styles, the style or null will be returned. If you are creating/modifying styles true will be returned.
None found |
askChoice(string $prompt, string|array $options, string|null $default = null) : mixed
Prompts the user for input based on a list of options, and returns it.
string | $prompt | Prompt text. |
string|array | $options | Array or string of options. |
string|null | $default | Default input value. |
Either the default value, or the user-provided input.
None found |
setLoggers(integer|boolean $enable) : void
Connects or disconnects the loggers to the console output.
Used to enable or disable logging stream output to stdout and stderr
If you don't wish all log output in stdout or stderr
through Cake's Log class, call this function with $enable=false
.
integer|boolean | $enable | Use a boolean to enable/toggle all logging. Use one of the verbosity constants (self::VERBOSE, self::QUIET, self::NORMAL) to control logging levels. VERBOSE enables debug logs, NORMAL does not include debug logs, QUIET disables notice, info and debug logs. |
None found |
helper(string $name, array $settings = array()) : \Cake\Console\Helper
Render a Console Helper
Create and render the output for a helper object. If the helper object has not already been loaded, it will be loaded and constructed.
string | $name | The name of the helper to render |
array | $settings | Configuration data for the helper. |
The created helper instance.
None found |
createFile(string $path, string $contents, boolean $forceOverwrite = false) : boolean
Create a file at the given path.
This method will prompt the user if a file will be overwritten.
Setting forceOverwrite
to true will suppress this behavior
and always overwrite the file.
If the user replies a
subsequent forceOverwrite
parameters will
be coerced to true and all files will be overwritten.
string | $path | The path to create the file at. |
string | $contents | The contents to put into the file. |
boolean | $forceOverwrite | Whether or not the file should be overwritten. If true, no question will be asked about whether or not to overwrite existing files. |
When q
is given as an answer
to whether or not a file should be overwritten.
Success.
None found |
wrapMessageWithType(string $messageType, string|array $message) : array|string
Wraps a message with a given message type, e.g. <warning>
string | $messageType | The message type, e.g. "warning". |
string|array | $message | The message to wrap. |
The message wrapped with the given message type.
None found |
_getInput(string $prompt, string|null $options, string|null $default) : string
Prompts the user for input, and returns it.
string | $prompt | Prompt text. |
string|null | $options | String of options. Pass null to omit. |
string|null | $default | Default input value. Pass null to omit. |
Either the default value, or the user-provided input.
None found |