Exemplo n.º 1
0
/**
 * 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);
		}
	}
 /**
  * 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));
 }
Exemplo n.º 3
0
 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)))))));
 }
Exemplo n.º 4
0
 /**
  * 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))));
 }
Exemplo n.º 5
0
 /**
  * getOptionParser
  *
  * @return array
  */
 public function getOptionParser()
 {
     return ConsoleOptionParser::buildFromArray(array('command' => 'Oven.bake', 'description' => array('Bakes an Oven recipe')));
 }
Exemplo n.º 6
0
 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']))))));
 }
Exemplo n.º 7
0
 /**
  * getOptionParser
  *
  * @return array
  */
 public function getOptionParser()
 {
     return ConsoleOptionParser::buildFromArray(array('command' => 'Oven.init', 'description' => array(__d('oven', 'Automatically initialize Oven')), 'options' => $this->_options));
 }
Exemplo n.º 8
0
 /**
  * {@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()))));
 }
Exemplo n.º 9
0
 /**
  * getOptionParser
  *
  * @return array
  */
 public function getOptionParser()
 {
     return ConsoleOptionParser::buildFromArray(array('command' => 'Oven.watch', 'description' => array('Watches for changes to a recipe then bakes')));
 }
Exemplo n.º 10
0
 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()));
 }