本文整理汇总了PHP中ConsoleOptionParser::addSubcommand方法的典型用法代码示例。如果您正苦于以下问题:PHP ConsoleOptionParser::addSubcommand方法的具体用法?PHP ConsoleOptionParser::addSubcommand怎么用?PHP ConsoleOptionParser::addSubcommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConsoleOptionParser
的用法示例。
在下文中一共展示了ConsoleOptionParser::addSubcommand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testXmlHelpSubcommand
/**
* test that help() outputs subcommands.
*
* @return void
*/
public function testXmlHelpSubcommand()
{
$parser = new ConsoleOptionParser('mycommand', false);
$parser->addSubcommand('method', array('help' => 'This is another command'))->addOption('test', array('help' => 'A test option.'));
$formatter = new HelpFormatter($parser);
$result = $formatter->xml();
$expected = <<<TEXT
<?xml version="1.0"?>
<shell>
<name>mycommand</name>
<description/>
<subcommands>
\t<command name="method" help="This is another command" />
</subcommands>
<options>
\t<option name="--help" short="-h" help="Display this help." boolean="1">
\t\t<default></default>
\t\t<choices></choices>
\t</option>
\t<option name="--test" short="" help="A test option." boolean="0">
\t\t<default></default>
\t\t<choices></choices>
\t</option>
</options>
<arguments/>
<epilog/>
</shell>
TEXT;
$this->assertEquals(new DomDocument($expected), new DomDocument($result), 'Help does not match');
}
示例2: testHelpSubcommandHelp
/**
* test that help() with a command param shows the help for a subcommand
*
* @return void
*/
public function testHelpSubcommandHelp()
{
$subParser = new ConsoleOptionParser('method', FALSE);
$subParser->addOption('connection', array('help' => 'Db connection.'));
$parser = new ConsoleOptionParser('mycommand', FALSE);
$parser->addSubcommand('method', array('help' => 'This is another command', 'parser' => $subParser))->addOption('test', array('help' => 'A test option.'));
$result = $parser->help('method');
$expected = <<<TEXT
<info>Usage:</info>
cake mycommand method [-h] [--connection]
<info>Options:</info>
--help, -h Display this help.
--connection Db connection.
TEXT;
$this->assertTextEquals($expected, $result, 'Help is not correct.');
}