Class HelpFormatter
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.
Property Summary
- 
        $_maxArgs protectedintThe maximum number of arguments shown when generating usage. 
- 
        $_maxOptions protectedintThe maximum number of options shown when generating usage. 
- 
        $_parser protectedCake\Console\ConsoleOptionParserOption parser. 
Method Summary
- 
          __construct() publicBuild the help formatter for an OptionParser 
- 
          _generateUsage() protectedGenerate 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 [] 
- 
          _getMaxLength() protectedIterate over a collection and find the longest named thing. 
- 
          text() publicGet the help as formatted text suitable for output on the command line. 
- 
          xml() publicGet the help as an xml string. 
Method Detail
__construct() ¶ public
__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. 
_generateUsage() ¶ protected
_generateUsage(): stringGenerate 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() ¶ protected
_getMaxLength(array $collection): intIterate over a collection and find the longest named thing.
Parameters
- 
                array$collection
- The collection to find a max length of. 
Returns
inttext() ¶ public
text(int $width = 72): stringGet the help as formatted text suitable for output on the command line.
Parameters
- 
                int$width optional
- The width of the help output. 
Returns
stringxml() ¶ public
xml(bool $string = true): string|SimpleXmlElementGet the help as an xml string.
Parameters
- 
                bool$string optional
- Return the SimpleXml object or a string. Defaults to true. 
Returns
string|SimpleXmlElementSee $string
