当前位置: 首页>>代码示例>>PHP>>正文


PHP ConsoleOptionParser::addSubcommand方法代码示例

本文整理汇总了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');
    }
开发者ID:SebFav,项目名称:ApplicationInternet2,代码行数:35,代码来源:HelpFormatterTest.php

示例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.');
    }
开发者ID:mrbadao,项目名称:api-official,代码行数:24,代码来源:ConsoleOptionParserTest.php


注:本文中的ConsoleOptionParser::addSubcommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。