本文整理汇总了PHP中Cake\Console\ConsoleOptionParser::arguments方法的典型用法代码示例。如果您正苦于以下问题:PHP ConsoleOptionParser::arguments方法的具体用法?PHP ConsoleOptionParser::arguments怎么用?PHP ConsoleOptionParser::arguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Console\ConsoleOptionParser
的用法示例。
在下文中一共展示了ConsoleOptionParser::arguments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _generateUsage
/**
* Generate the usage for a shell based on its arguments and options.
* Usage strings favor short options over the long ones. and optional args will
* be indicated with []
*
* @return string
*/
protected function _generateUsage()
{
$usage = ['cake ' . $this->_parser->command()];
$subcommands = $this->_parser->subcommands();
if (!empty($subcommands)) {
$usage[] = '[subcommand]';
}
$options = [];
foreach ($this->_parser->options() as $option) {
$options[] = $option->usage();
}
if (count($options) > $this->_maxOptions) {
$options = ['[options]'];
}
$usage = array_merge($usage, $options);
$args = [];
foreach ($this->_parser->arguments() as $argument) {
$args[] = $argument->usage();
}
if (count($args) > $this->_maxArgs) {
$args = ['[arguments]'];
}
$usage = array_merge($usage, $args);
return implode(' ', $usage);
}
示例2: testPositionalArgOverwrite
/**
* test overwriting positional arguments.
*
* @return void
*/
public function testPositionalArgOverwrite()
{
$parser = new ConsoleOptionParser('test', false);
$parser->addArgument('name', ['help' => 'An argument'])->addArgument('other', ['index' => 0]);
$result = $parser->arguments();
$this->assertEquals(1, count($result), 'Overwrite did not occur');
}