当前位置: 首页>>代码示例>>PHP>>正文


PHP ConsoleOptionParser::buildFromArray方法代码示例

本文整理汇总了PHP中Cake\Console\ConsoleOptionParser::buildFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ConsoleOptionParser::buildFromArray方法的具体用法?PHP ConsoleOptionParser::buildFromArray怎么用?PHP ConsoleOptionParser::buildFromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Console\ConsoleOptionParser的用法示例。


在下文中一共展示了ConsoleOptionParser::buildFromArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Make a new Subcommand
  *
  * @param string|array $name The long name of the subcommand, or an array with all the properties.
  * @param string $help The help text for this option.
  * @param \Cake\Console\ConsoleOptionParser|array|null $parser A parser for this subcommand. Either a ConsoleOptionParser, or an
  *   array that can be used with ConsoleOptionParser::buildFromArray().
  */
 public function __construct($name, $help = '', $parser = null)
 {
     if (is_array($name) && isset($name['name'])) {
         foreach ($name as $key => $value) {
             $this->{'_' . $key} = $value;
         }
     } else {
         $this->_name = $name;
         $this->_help = $help;
         $this->_parser = $parser;
     }
     if (is_array($this->_parser)) {
         $this->_parser['command'] = $this->_name;
         $this->_parser = ConsoleOptionParser::buildFromArray($this->_parser);
     }
 }
开发者ID:rederlo,项目名称:cakephp,代码行数:24,代码来源:ConsoleInputSubcommand.php

示例2: testToArray

 /**
  * Tests toArray()
  *
  * @return void
  */
 public function testToArray()
 {
     $spec = ['command' => 'test', 'arguments' => ['name' => ['help' => 'The name'], 'other' => ['help' => 'The other arg']], 'options' => ['name' => ['help' => 'The name'], 'other' => ['help' => 'The other arg']], 'subcommands' => ['initdb' => ['help' => 'make database']], 'description' => 'description text', 'epilog' => 'epilog text'];
     $parser = ConsoleOptionParser::buildFromArray($spec);
     $result = $parser->toArray();
     $this->assertEquals($spec['description'], $result['description']);
     $this->assertEquals($spec['epilog'], $result['epilog']);
     $options = $result['options'];
     $this->assertTrue(isset($options['name']));
     $this->assertTrue(isset($options['other']));
     $this->assertEquals(2, count($result['arguments']));
     $this->assertEquals(1, count($result['subcommands']));
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:18,代码来源:ConsoleOptionParserTest.php

示例3: testBuildFromArray

 /**
  * test building a parser from an array.
  *
  * @return void
  */
 public function testBuildFromArray()
 {
     $spec = array('command' => 'test', 'arguments' => array('name' => array('help' => 'The name'), 'other' => array('help' => 'The other arg')), 'options' => array('name' => array('help' => 'The name'), 'other' => array('help' => 'The other arg')), 'subcommands' => array('initdb' => array('help' => 'make database')), 'description' => 'description text', 'epilog' => 'epilog text');
     $parser = ConsoleOptionParser::buildFromArray($spec);
     $this->assertEquals($spec['description'], $parser->description());
     $this->assertEquals($spec['epilog'], $parser->epilog());
     $options = $parser->options();
     $this->assertTrue(isset($options['name']));
     $this->assertTrue(isset($options['other']));
     $args = $parser->arguments();
     $this->assertEquals(2, count($args));
     $commands = $parser->subcommands();
     $this->assertEquals(1, count($commands));
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:19,代码来源:ConsoleOptionParserTest.php


注:本文中的Cake\Console\ConsoleOptionParser::buildFromArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。