\Cake\ConsoleHelpFormatter

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.

Summary

Methods
Properties
Constants
__construct()
setAlias()
text()
xml()
No public properties found
No constants found
_generateUsage()
_getMaxLength()
$_maxArgs
$_maxOptions
$_parser
$_alias
N/A
No private methods found
No private properties found
N/A

Properties

$_maxArgs

$_maxArgs : integer

The maximum number of arguments shown when generating usage.

Type

integer

$_maxOptions

$_maxOptions : integer

The maximum number of options shown when generating usage.

Type

integer

$_alias

$_alias : string

Alias to display in the output.

Type

string

Methods

__construct()

__construct(\Cake\Console\ConsoleOptionParser  $parser) 

Build the help formatter for an OptionParser

Parameters

\Cake\Console\ConsoleOptionParser $parser

The option parser help is being generated for.

setAlias()

setAlias(string  $alias) : void

Set the alias

Parameters

string $alias

The alias

Throws

\Cake\Console\Exception\ConsoleException

When alias is not a string.

text()

text(integer  $width = 72) : string

Get the help as formatted text suitable for output on the command line.

Parameters

integer $width

The width of the help output.

Returns

string

xml()

xml(boolean  $string = true) : string|\SimpleXMLElement

Get the help as an xml string.

Parameters

boolean $string

Return the SimpleXml object or a string. Defaults to true.

Returns

string|\SimpleXMLElement —

See $string

_generateUsage()

_generateUsage() : string

Generate the usage for a shell based on its arguments and options.

Usage strings favor short options over the long ones. and optional args will be indicated with []

Returns

string

_getMaxLength()

_getMaxLength(array  $collection) : integer

Iterate over a collection and find the longest named thing.

Parameters

array $collection

The collection to find a max length of.

Returns

integer