/** * Display the help in the correct format * * @param string $command * @return void */ protected function _displayHelp($command) { $format = 'text'; if (!empty($this->args[0]) && $this->args[0] == 'xml') { $format = 'xml'; $this->stdout->outputAs(ConsoleOutput::RAW); } else { $this->_welcome(); } return $this->out($this->OptionParser->help($command, $format)); }
public function getOptionParser() { $parser = new ConsoleOptionParser($this->name); $parser->description(__('RADIUSdesk console for various tasks')); $parser->addOption('ping', array('help' => 'Do a ping monitor test', 'boolean' => true)); $parser->addOption('heartbeat', array('help' => 'Do a heartbeat monitor test', 'boolean' => true)); $parser->addArgument('action', array('help' => 'The action to do', 'required' => true, 'choices' => array('mon', 'restart_check', 'debug_check', 'auto_close'))); $parser->epilog('Have alot of fun....'); return $parser; }
/** * 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); } }
/** * Build a parser from an array. Uses an array like * * {{{ * $spec = array( * 'description' => 'text', * 'epilog' => 'text', * 'arguments' => array( * // list of arguments compatible with addArguments. * ), * 'options' => array( * // list of options compatible with addOptions * ), * 'subcommands' => array( * // list of subcommands to add. * ) * ); * }}} * * @param array $spec The spec to build the OptionParser with. * @return ConsoleOptionParser */ public static function buildFromArray($spec) { $parser = new ConsoleOptionParser($spec['command']); if (!empty($spec['arguments'])) { $parser->addArguments($spec['arguments']); } if (!empty($spec['options'])) { $parser->addOptions($spec['options']); } if (!empty($spec['subcommands'])) { $parser->addSubcommands($spec['subcommands']); } if (!empty($spec['description'])) { $parser->description($spec['description']); } if (!empty($spec['epilog'])) { $parser->epilog($spec['epilog']); } return $parser; }
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))))))); }
/** * Gets the option parser instance and configures it. * * @return ConsoleOptionParser */ public function getOptionParser() { $parser = new ConsoleOptionParser($this->name); $parser->description(__d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line'))->addArgument('category', array('help' => __d('cake_console', 'The category for the test, or test file, to test.'), 'required' => false))->addArgument('file', array('help' => __d('cake_console', 'The path to the file, or test file, to test.'), 'required' => false))->addOption('log-junit', array('help' => __d('cake_console', '<file> Log test execution in JUnit XML format to file.'), 'default' => false))->addOption('log-json', array('help' => __d('cake_console', '<file> Log test execution in JSON format to file.'), 'default' => false))->addOption('log-tap', array('help' => __d('cake_console', '<file> Log test execution in TAP format to file.'), 'default' => false))->addOption('log-dbus', array('help' => __d('cake_console', 'Log test execution to DBUS.'), 'default' => false))->addOption('coverage-html', array('help' => __d('cake_console', '<dir> Generate code coverage report in HTML format.'), 'default' => false))->addOption('coverage-clover', array('help' => __d('cake_console', '<file> Write code coverage data in Clover XML format.'), 'default' => false))->addOption('testdox-html', array('help' => __d('cake_console', '<file> Write agile documentation in HTML format to file.'), 'default' => false))->addOption('testdox-text', array('help' => __d('cake_console', '<file> Write agile documentation in Text format to file.'), 'default' => false))->addOption('filter', array('help' => __d('cake_console', '<pattern> Filter which tests to run.'), 'default' => false))->addOption('group', array('help' => __d('cake_console', '<name> Only runs tests from the specified group(s).'), 'default' => false))->addOption('exclude-group', array('help' => __d('cake_console', '<name> Exclude tests from the specified group(s).'), 'default' => false))->addOption('list-groups', array('help' => __d('cake_console', 'List available test groups.'), 'boolean' => true))->addOption('loader', array('help' => __d('cake_console', 'TestSuiteLoader implementation to use.'), 'default' => false))->addOption('repeat', array('help' => __d('cake_console', '<times> Runs the test(s) repeatedly.'), 'default' => false))->addOption('tap', array('help' => __d('cake_console', 'Report test execution progress in TAP format.'), 'boolean' => true))->addOption('testdox', array('help' => __d('cake_console', 'Report test execution progress in TestDox format.'), 'default' => false, 'boolean' => true))->addOption('no-colors', array('help' => __d('cake_console', 'Do not use colors in output.'), 'boolean' => true))->addOption('stderr', array('help' => __d('cake_console', 'Write to STDERR instead of STDOUT.'), 'boolean' => true))->addOption('stop-on-error', array('help' => __d('cake_console', 'Stop execution upon first error or failure.'), 'boolean' => true))->addOption('stop-on-failure', array('help' => __d('cake_console', 'Stop execution upon first failure.'), 'boolean' => true))->addOption('stop-on-skipped', array('help' => __d('cake_console', 'Stop execution upon first skipped test.'), 'boolean' => true))->addOption('stop-on-incomplete', array('help' => __d('cake_console', 'Stop execution upon first incomplete test.'), 'boolean' => true))->addOption('strict', array('help' => __d('cake_console', 'Mark a test as incomplete if no assertions are made.'), 'boolean' => true))->addOption('wait', array('help' => __d('cake_console', 'Waits for a keystroke after each test.'), 'boolean' => true))->addOption('process-isolation', array('help' => __d('cake_console', 'Run each test in a separate PHP process.'), 'boolean' => true))->addOption('no-globals-backup', array('help' => __d('cake_console', 'Do not backup and restore $GLOBALS for each test.'), 'boolean' => true))->addOption('static-backup', array('help' => __d('cake_console', 'Backup and restore static attributes for each test.'), 'boolean' => true))->addOption('syntax-check', array('help' => __d('cake_console', 'Try to check source files for syntax errors.'), 'boolean' => true))->addOption('bootstrap', array('help' => __d('cake_console', '<file> A "bootstrap" PHP file that is run before the tests.'), 'default' => false))->addOption('configuration', array('help' => __d('cake_console', '<file> Read configuration from XML file.'), 'default' => false))->addOption('no-configuration', array('help' => __d('cake_console', 'Ignore default configuration file (phpunit.xml).'), 'boolean' => true))->addOption('include-path', array('help' => __d('cake_console', '<path(s)> Prepend PHP include_path with given path(s).'), 'default' => false))->addOption('directive', array('help' => __d('cake_console', 'key[=value] Sets a php.ini value.'), 'default' => false))->addOption('fixture', array('help' => __d('cake_console', 'Choose a custom fixture manager.')))->addOption('debug', array('help' => __d('cake_console', 'More verbose output.'))); return $parser; }
/** * ConvertShell::getOptionParser() * * @return ConsoleOptionParser */ public function getOptionParser() { $subcommandParser = array('options' => array('plugin' => array('short' => 'p', 'help' => 'The plugin to update. Only the specified plugin will be updated.', 'default' => ''), 'dry-run' => array('short' => 'd', 'help' => 'Dry run the update, no files will actually be modified.', 'boolean' => true), 'ext' => array('short' => 'e', 'help' => 'The extension(s) to search. A pipe delimited list, or a preg_match compatible subpattern', 'default' => 'php')), 'arguments' => ['path' => ['help' => 'Path to folder, defaults to current APP otherwise.']]); $name = ($this->plugin ? $this->plugin . '.' : '') . $this->name; $parser = new ConsoleOptionParser($name); return $parser->description("A shell to help automate upgrading array syntax to PHP5.4")->addSubcommand('run', array('help' => 'Update verbose array syntax to short one.', 'parser' => $subcommandParser)); }
/** * getOptionParser * * @return array */ public function getOptionParser() { return ConsoleOptionParser::buildFromArray(array('command' => 'Oven.bake', 'description' => array('Bakes an Oven recipe'))); }
/** * ConvertShell::getOptionParser() * * @return ConsoleOptionParser */ public function getOptionParser() { $subcommandParser = array('options' => array('plugin' => array('short' => 'p', 'help' => __d('cake_console', 'The plugin to update. Only the specified plugin will be updated.'), 'default' => ''), 'dry-run' => array('short' => 'd', 'help' => __d('cake_console', 'Dry run the update, no files will actually be modified.'), 'boolean' => true), 'ext' => array('short' => 'e', 'help' => __d('cake_console', 'The extension(s) to search. A pipe delimited list, or a preg_match compatible subpattern'), 'default' => 'php'))); $name = ($this->plugin ? $this->plugin . '.' : '') . $this->name; $parser = new ConsoleOptionParser($name); return $parser->description(__d('cake_console', "A shell to help automate upgrading array syntax to PHP5.4"))->addSubcommand('arrays', array('help' => __d('cake_console', 'Main method to update verbose array syntax to short one.'), 'parser' => $subcommandParser)); }
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'])))))); }
/** * getOptionParser * * @return array */ public function getOptionParser() { return ConsoleOptionParser::buildFromArray(array('command' => 'Oven.init', 'description' => array(__d('oven', 'Automatically initialize Oven')), 'options' => $this->_options)); }
/** * {@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())))); }
/** * getOptionParser * * @return array */ public function getOptionParser() { return ConsoleOptionParser::buildFromArray(array('command' => 'Oven.watch', 'description' => array('Watches for changes to a recipe then bakes'))); }
/** * test that parse() takes a subcommand argument, and that the subcommand parser * is used. * * @return void */ public function testParsingWithSubParser() { $parser = new ConsoleOptionParser('test', FALSE); $parser->addOption('primary')->addArgument('one', array('required' => TRUE, 'choices' => array('a', 'b')))->addArgument('two', array('required' => TRUE))->addSubcommand('sub', array('parser' => array('options' => array('secondary' => array('boolean' => TRUE), 'fourth' => array('help' => 'fourth option')), 'arguments' => array('sub_arg' => array('choices' => array('c', 'd')))))); $result = $parser->parse(array('--secondary', '--fourth', '4', 'c'), 'sub'); $expected = array(array('secondary' => TRUE, 'fourth' => '4', 'help' => FALSE, 'verbose' => FALSE, 'quiet' => FALSE), array('c')); $this->assertEquals($expected, $result, 'Sub parser did not parse request.'); }
/** * 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)))); }
/** * Test xml help as object * * @return void */ public function testXmlHelpAsObject() { $parser = new ConsoleOptionParser('mycommand', false); $parser->addOption('test', array('help' => 'A test option.'))->addArgument('model', array('help' => 'The model to make.', 'required' => true))->addArgument('other_longer', array('help' => 'Another argument.')); $formatter = new HelpFormatter($parser); $result = $formatter->xml(false); $this->assertInstanceOf('SimpleXmlElement', $result); }
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())); }