本文整理汇总了PHP中Cake\Console\ConsoleOptionParser::command方法的典型用法代码示例。如果您正苦于以下问题:PHP ConsoleOptionParser::command方法的具体用法?PHP ConsoleOptionParser::command怎么用?PHP ConsoleOptionParser::command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Console\ConsoleOptionParser
的用法示例。
在下文中一共展示了ConsoleOptionParser::command方法的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: testCommandInflection
/**
* test that command() inflects the command name.
*
* @return void
*/
public function testCommandInflection()
{
$parser = new ConsoleOptionParser('CommandLine');
$this->assertEquals('command_line', $parser->command());
}