本文整理汇总了PHP中Cake\Console\ConsoleOptionParser::addArgument方法的典型用法代码示例。如果您正苦于以下问题:PHP ConsoleOptionParser::addArgument方法的具体用法?PHP ConsoleOptionParser::addArgument怎么用?PHP ConsoleOptionParser::addArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Console\ConsoleOptionParser
的用法示例。
在下文中一共展示了ConsoleOptionParser::addArgument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHelpWithLotsOfArguments
/**
* Test that a long set of arguments doesn't make useless output.
*
* @return void
*/
public function testHelpWithLotsOfArguments()
{
$parser = new ConsoleOptionParser('mycommand', false);
$parser->addArgument('test', ['help' => 'A test option.'])->addArgument('test2', ['help' => 'A test option.'])->addArgument('test3', ['help' => 'A test option.'])->addArgument('test4', ['help' => 'A test option.'])->addArgument('test5', ['help' => 'A test option.'])->addArgument('test6', ['help' => 'A test option.'])->addArgument('test7', ['help' => 'A test option.'])->addArgument('model', ['help' => 'The model to make.', 'required' => true])->addArgument('other_longer', ['help' => 'Another argument.']);
$formatter = new HelpFormatter($parser);
$result = $formatter->text();
$expected = 'cake mycommand [-h] [arguments]';
$this->assertContains($expected, $result);
}
示例2: testPositionalArgWithChoices
/**
* test that arguments with choices enforce them.
*
* @expectedException \Cake\Console\Exception\ConsoleException
* @return void
*/
public function testPositionalArgWithChoices()
{
$parser = new ConsoleOptionParser('test', false);
$parser->addArgument('name', ['choices' => ['mark', 'jose']])->addArgument('alias', ['choices' => ['cowboy', 'samurai']])->addArgument('weapon', ['choices' => ['gun', 'sword']]);
$result = $parser->parse(['mark', 'samurai', 'sword']);
$expected = ['mark', 'samurai', 'sword'];
$this->assertEquals($expected, $result[1], 'Got the correct value.');
$result = $parser->parse(['jose', 'coder']);
}