本文整理匯總了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']);
}