本文整理汇总了PHP中ConsoleOptionParser::buildFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ConsoleOptionParser::buildFromArray方法的具体用法?PHP ConsoleOptionParser::buildFromArray怎么用?PHP ConsoleOptionParser::buildFromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConsoleOptionParser
的用法示例。
在下文中一共展示了ConsoleOptionParser::buildFromArray方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ConsoleOptionParser|array $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);
}
}
示例2: 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));
}
示例3: getOptionParser
public function getOptionParser()
{
$options = array('working' => array('short' => 'w', 'help' => __('Set working directory for project to be baked in.'), 'boolean' => false), 'skel' => array('short' => 's', 'help' => __('Skel to bake from.'), 'boolean' => false, 'default' => $this->_pluginPath('BakingPlate') . 'Console' . DS . 'Templates' . DS . 'skel'), 'config' => array('short' => 'c', 'help' => __('Config file of submodules to bake into project.'), 'boolean' => false), 'group' => array('short' => 'g', 'help' => __('Specify a group of submodules, or core will be used.'), 'boolean' => false));
return ConsoleOptionParser::buildFromArray(array('command' => 'plate', 'description' => __('BakingPlate Plate Shell Help.'), 'options' => array('group' => $options['group'], 'config' => $options['config']), 'subcommands' => array('init' => array('help' => __('Initializes BakingPlate tweaks onto an existing project'), 'parser' => array('description' => array(__('Initializes a git repository'), __('Makes necessary folders writeable'), __('Adds core (or specified) plugins to the project')), 'options' => array('config' => $options['config'], 'group' => $options['group']))), 'bake' => array('help' => __('Generates a new app using bakeplate.'), 'parser' => array('description' => __('The plate shell will bake a project from a skel. It will then add submodules and set permissions on folders.'), 'options' => array('working' => $options['working'], 'skel' => $options['skel'], 'config' => $options['config'], 'group' => array_merge(array('default' => 'core'), $options['group'])), 'arguments' => array('working' => array()))), 'browse' => array('help' => __('List available submodules.'), 'parser' => array('description' => __('Browse listed submodules (or groups of submodules) via name or index number.'), 'options' => array('group' => $options['group'], 'config' => $options['config']), 'arguments' => array('group' => array('help' => __('name or number of group.'), 'required' => false)))), 'add' => array('help' => __('Add specific submodule.'), 'parser' => array('description' => __('Add individual plugins as submodules to your project'), 'options' => array('group' => $options['group']), 'arguments' => array('submodule' => array('help' => __('Submodule to be added.'), 'required' => true)))), 'all' => array('help' => __('All submodules in a specified batch group'), 'parser' => array('description' => __('All submodules in a specified batch group'), 'options' => array(), 'arguments' => array())), 'search' => array('help' => __('Search for a specific submodule to install from CakePackages.com'), 'parser' => array('description' => __('Search <info>cakepackages.com</info> for Vendors or Plugins to add as submodules to Application'), 'options' => array(), 'arguments' => array('term' => array('help' => __('Search for a Cake Package to be add.'), 'required' => true)))))));
}
示例4: getOptionParser
/**
* getOptionParser
*
* @return array
*/
public function getOptionParser()
{
return ConsoleOptionParser::buildFromArray(array('command' => 'Oven.merge', 'description' => array('Merges two classes.'), 'arguments' => array('from' => array('help' => __d('Oven', 'Class to merge from, `Controller/CommentsController`.'), 'required' => true), 'to' => array('help' => __d('Oven', 'Class to merge to, `Controller/BlogsController`.'), 'required' => true))));
}
示例5: getOptionParser
/**
* getOptionParser
*
* @return array
*/
public function getOptionParser()
{
return ConsoleOptionParser::buildFromArray(array('command' => 'Oven.bake', 'description' => array('Bakes an Oven recipe')));
}
示例6: getOptionParser
public function getOptionParser()
{
$options = array('theme' => array('short' => 't', 'help' => __('Set theme to place Bootstrap files in.'), 'boolean' => false), 'webroot' => array('short' => 'w', 'help' => __('Set file output to webroot Theme dir (use with theme option).'), 'boolean' => true));
return ConsoleOptionParser::buildFromArray(array('command' => 'copy', 'description' => __('TwitterBootstrap Copy Shell Help.'), 'options' => array('theme' => $options['theme'], 'webroot' => $options['webroot']), 'subcommands' => array('all' => array('help' => __('Copies Less, Js & Img source from Bootstrap submodule in plugin Vendor dir'), 'parser' => array('description' => array(__('files will be placed in webroot of App or named Theme')), 'options' => array('theme' => $options['theme'], 'webroot' => $options['webroot']))), 'less' => array('help' => __('Copies Less source from Bootstrap submodule in plugin Vendor dir'), 'parser' => array('description' => array(__('files will be placed in webroot/css/lib/ of App or named Theme')), 'options' => array('theme' => $options['theme'], 'webroot' => $options['webroot']))), 'img' => array('help' => __('Copies Img source from Bootstrap submodule in plugin Vendor dir'), 'parser' => array('description' => array(__('files will be placed in webroot/img/ of App or named Theme')), 'options' => array('theme' => $options['theme'], 'webroot' => $options['webroot']))), 'js' => array('help' => __('Copies Js source from Bootstrap submodule in plugin Vendor dir'), 'parser' => array('description' => array(__('files will be placed in webroot/js/lib of App or named Theme')), 'options' => array('theme' => $options['theme'], 'webroot' => $options['webroot']))))));
}
示例7: getOptionParser
/**
* getOptionParser
*
* @return array
*/
public function getOptionParser()
{
return ConsoleOptionParser::buildFromArray(array('command' => 'Oven.init', 'description' => array(__d('oven', 'Automatically initialize Oven')), 'options' => $this->_options));
}
示例8: getOptionParser
/**
* {@inheritdoc}
*/
public function getOptionParser()
{
return ConsoleOptionParser::buildFromArray(array('command' => 'clear_cache', 'description' => array(__d('webmaster', "Clear application's cache")), 'options' => array('expired' => array('help' => __d('webmaster', 'Cache configuration to use in conjunction with `toolkit clear`.'), 'short' => 'e', 'boolean' => true, 'default' => false), 'config' => array('help' => __d('webmaster', "Specify the cache configuration's name."), 'short' => 'c', 'choices' => Cache::configured()))));
}
示例9: getOptionParser
public function getOptionParser()
{
return ConsoleOptionParser::buildFromArray(array('description' => array(__("Export images containing a given Tag cropped")), 'arguments' => array('dest' => array('help' => __('path where will be stored output images'), 'required' => true), 'tagId' => array('help' => __('Tag Id'))), 'options' => array()));
}