本文整理汇总了PHP中ConsoleOptionParser::addArgument方法的典型用法代码示例。如果您正苦于以下问题:PHP ConsoleOptionParser::addArgument方法的具体用法?PHP ConsoleOptionParser::addArgument怎么用?PHP ConsoleOptionParser::addArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConsoleOptionParser
的用法示例。
在下文中一共展示了ConsoleOptionParser::addArgument方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptionParser
public function getOptionParser()
{
$parser = new ConsoleOptionParser($this->name);
$parser->description(__('RADIUSdesk console for various tasks'));
$parser->addOption('ping', array('help' => 'Do a ping monitor test', 'boolean' => true));
$parser->addOption('heartbeat', array('help' => 'Do a heartbeat monitor test', 'boolean' => true));
$parser->addArgument('action', array('help' => 'The action to do', 'required' => true, 'choices' => array('mon', 'restart_check', 'debug_check', 'auto_close')));
$parser->epilog('Have alot of fun....');
return $parser;
}
示例2: 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', array('help' => 'A test option.'))->addArgument('test2', array('help' => 'A test option.'))->addArgument('test3', array('help' => 'A test option.'))->addArgument('test4', array('help' => 'A test option.'))->addArgument('test5', array('help' => 'A test option.'))->addArgument('test6', array('help' => 'A test option.'))->addArgument('test7', array('help' => 'A test option.'))->addArgument('model', array('help' => 'The model to make.', 'required' => true))->addArgument('other_longer', array('help' => 'Another argument.'));
$formatter = new HelpFormatter($parser);
$result = $formatter->text();
$expected = 'cake mycommand [-h] [arguments]';
$this->assertContains($expected, $result);
}
示例3: testPositionalArgWithChoices
/**
* test that arguments with choices enforce them.
*
* @expectedException ConsoleException
* @return void
*/
public function testPositionalArgWithChoices()
{
$parser = new ConsoleOptionParser('test', FALSE);
$parser->addArgument('name', array('choices' => array('mark', 'jose')))->addArgument('alias', array('choices' => array('cowboy', 'samurai')))->addArgument('weapon', array('choices' => array('gun', 'sword')));
$result = $parser->parse(array('mark', 'samurai', 'sword'));
$expected = array('mark', 'samurai', 'sword');
$this->assertEquals($expected, $result[1], 'Got the correct value.');
$parser->parse(array('jose', 'coder'));
}