Manage available options via Parser

@return \Cake\Console\ConsoleOptionParser
774730
public function getOptionParser()
    {
        $parser = parent::getOptionParser();
        $parser->setDescription(
            (string)__('Synchronize local and remote calendars with the database')
        );

        $parser->addOption('start', [
            'description' => (string)__('Specify start interval for the events to fetch'),
            'help' => (string)__("Start date 'YYYY-MM-DD HH:MM:SS' for events to fetch"),
        ]);

        $parser->addOption('end', [
            'description' => (string)__('Specify end interval for the events to fetch'),
            'help' => (string)__("End date 'YYYY-MM-DD HH:MM:SS' for events to fetch"),
        ]);

        return $parser;
    }
1283938
public function getOptionParser() {
		$parser = parent::getOptionParser();

		$parser->addSubcommands([
			CAKE_LDAP_SHELL_CRON_TASK_SYNC => [
					'help' => __d('cake_ldap', 'Sync information of employees with LDAP server'),
					'parser' => $this->Sync->getOptionParser()
			]]);

		return $parser;
	}
1083221
public function getOptionParser()
    {
        $parser = parent::getOptionParser();
        $parser->addSubcommand('list_prefixes', [
            'help' => 'Show a list of all defined cache prefixes.',
        ]);
        $parser->addSubcommand('clear_all', [
            'help' => 'Clear all caches.',
        ]);
        $parser->addSubcommand('clear', [
            'help' => 'Clear the cache for a specified prefix.',
            'parser' => [
                'description' => [
                    'Clear the cache for a particular prefix.',
                    'For example, `cake cache clear _cake_model_` will clear the model cache',
                    'Use `cake cache list_prefixes` to list available prefixes'
                ],
                'arguments' => [
                    'prefix' => [
                        'help' => 'The cache prefix to be cleared.',
                        'required' => true
                    ]
                ]
            ]
        ]);

        return $parser;
    }
554219
protected function _parseOptions($options)
    {
        if (!empty($options['label']) && $options['label']) {
            if (!is_array($options['label'])) {
                $options['label'] = ['text' => $options['label']];
            }
            $options['label'] = array_merge_recursive($options['label'], ['class' => 'control-label']);
        }
        return parent::_parseOptions($options);
    }
314219
protected function get_options() {
        global $CFG;
        $options = parent::get_options();
        $options['file'] = $CFG->admin.'/webservice/lib.php'; //need to be set, otherwise
                                                        // the /user/selector/search.php
                                                        //will fail to find this user_selector class
        $options['serviceid'] = $this->serviceid;
        $options['displayallowedusers'] = $this->displayallowedusers;
        return $options;
    }
1267199
protected function setOption() {
		
		// find the value that was passed
		$updateOption = Console::findCommandOptionValue("set");
		$updateOptionBits = explode("=",$updateOption);
		if (count($updateOptionBits) == 1) {
			Console::writeError("the --set value should look like <info>optionName=\"optionValue\"</info>. nothing was updated...");
		}
		
		// set the name and value that were passed
		$updateName   = $updateOptionBits[0];
		$updateValue  = (($updateOptionBits[1][0] == "\"") || ($updateOptionBits[1][0] == "'")) ? substr($updateOptionBits[1],1,strlen($updateOptionBits[1])-1) : $updateOptionBits[1];
		
		// make sure the option being updated already exists
		$currentValue = Config::getOption($updateName);
		
		if (!$currentValue) {
			Console::writeError("the --set option you provided, <info>".$updateName."</info>, does not exists in the config. nothing will be updated...");
		} else {
			Config::updateConfigOption($updateName,$updateValue);
			Console::writeInfo("config option updated...");
		}
		
	}
1132313
protected function getOptions()
	{
		$options = array();

		foreach ($this->element->children() as $option)
		{
			// Only add <option /> elements.
			if ($option->getName() != 'option')
			{
				continue;
			}

			// Create a new option object based on the <option /> element.
			$tmp = HtmlSelect::option(
				(string) $option['value'],
				Text::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)), 'value', 'text',
				((string) $option['disabled'] == 'true')
			);

			// Set some option attributes.
			$tmp->class = (string) $option['class'];

			// Set some JavaScript option attributes.
			$tmp->onclick = (string) $option['onclick'];

			// Add the option object to the result set.
			$options[] = $tmp;
		}

		reset($options);

		return $options;
	}
819131
public function getOptionParser() {
		$parser = parent::getOptionParser();
		$parser->description('There is no help');
		$taskNames = array_keys(Hash::normalize($this->tasks));
		foreach ($taskNames as $taskName) {
			$Task = $this->{$taskName};
			$parser->addSubcommand(Inflector::underscore($Task->name), array(
				'help' => $Task->getOptionParser()->description(),
				'parser' => $Task->getOptionParser()
			));
		}
		return $parser;
	}
688662
public function getOptions() {
        if (is_null($this->result)) {
            $this->parse();
        }
        return $this->result[Parser::RESULT_OPTIONS];
    }
1002442
public function getOptionParser() {
		$parser = parent::getOptionParser();
		$parser->addArgument('name(s)', array(
			'required' => true,
			'help' => 'Enter one or more cache/view names separated by comma or "all"' .
			"\n<comment>(choises: " . implode(',', array_merge(Cache::configured(), array('all'))) . ")</comment>"
		));
		$parser->addOption('views', array(
			'boolean' => true,
			'help' => 'If set views files will be deleted' .
			"\n<comment>(choises: " . implode(',', array('view_file_name*', 'all')) . ")</comment>"
		));
		return $parser->description('Clear cache');
	}
83074
protected function buildOptionParser(ConsoleOptionParser $parser)
    {
        $parser->setDescription(__d('link-scanner', 'Performs a complete scan'));

        return $parser->addOptions([
            'export' => [
                'boolean' => true,
                'default' => false,
                'help' => __d('link-scanner', 'Export results. The filename will be generated automatically'),
                'short' => 'e',
            ],
            'export-with-filename' => [
                'help' => __d('link-scanner', 'Export results. You must pass a relative or absolute path'),
            ],
            'follow-redirects' => [
                'boolean' => true,
                'default' => false,
                'help' => __d('link-scanner', 'Follows redirect'),
            ],
            'force' => [
                'boolean' => true,
                'default' => false,
                'help' => __d('link-scanner', 'Force mode: removes the lock file and does not ask questions'),
                'short' => 'f',
            ],
            'full-base-url' => [
                'help' => __d('link-scanner', 'Full base url. By default, the `{0}` value will be used', 'App.fullBaseUrl'),
            ],
            'max-depth' => [
                'help' => __d('link-scanner', 'Maximum depth of the scan. Default: {0}', $this->LinkScanner->getConfig('maxDepth')),
                'short' => 'd',
            ],
            'no-cache' => [
                'boolean' => true,
                'default' => false,
                'help' => __d('link-scanner', 'Disables the cache'),
            ],
            'no-external-links' => [
                'boolean' => true,
                'default' => false,
                'help' => __d('link-scanner', 'Disable the scanning of external links'),
            ],
            'timeout' => [
                'help' => __d('link-scanner', 'Timeout in seconds for GET requests. Default: {0}', $this->LinkScanner->Client->getConfig('timeout')),
                'short' => 't',
            ],
        ]);
    }
880043
public function getOptionParser()
    {
        $parser = parent::getOptionParser();

        $parser->setDescription('Plugin Shell perform various tasks related to plugin.')
            ->addSubcommand('assets', [
                'help' => 'Symlink / copy plugin assets to app\'s webroot',
                'parser' => $this->Assets->getOptionParser()
            ])
            ->addSubcommand('loaded', [
                'help' => 'Lists all loaded plugins',
                'parser' => $parser,
            ])
            ->addSubcommand('load', [
                'help' => 'Loads a plugin',
                'parser' => $this->Load->getOptionParser(),
            ])
            ->addSubcommand('unload', [
                'help' => 'Unloads a plugin',
                'parser' => $this->Unload->getOptionParser(),
            ]);

        return $parser;
    }
205481
public function parse_options()
    {
        $getopt = new Getopt([
            ['d', 'directory', Getopt::REQUIRED_ARGUMENT, 'Run under given directory'],
            ['l', 'level', Getopt::REQUIRED_ARGUMENT, 'Practice level on epic'],
            ['s', 'skip', Getopt::NO_ARGUMENT, 'Skip user input'],
            ['t', 'time', Getopt::REQUIRED_ARGUMENT, 'Delay each turn by seconds'],
            ['L', 'locale', Getopt::REQUIRED_ARGUMENT, 'Specify locale like en_US'],
            ['h', 'help', Getopt::NO_ARGUMENT, 'Show this message'],
        ]);
        try {
            $getopt->parse();
        } catch (\Exception $e) {
            echo $e->getMessage() . "\n";
            exit;
        }
        if ($getopt->getOption('h')) {
            echo $getopt->getHelpText();
            exit;
        }
        if ($getopt->getOption('d')) {
            Config::$path_prefix = $getopt->getOption('d');
        }
        if ($getopt->getOption('l')) {
            Config::$practice_level = $getopt->getOption('l');
        }
        if ($getopt->getOption('s')) {
            Config::$skip_input = true;
        }
        if (!is_null($getopt->getOption('t'))) {
            Config::$delay = $getopt->getOption('t');
        }
        // get locale from $LANG like en_US.UTF8
        list(Config::$locale) = explode('.', getenv('LANG'));
        if ($getopt->getOption('L')) {
            Config::$locale = $getopt->getOption('L');
        }
    }
1360620
protected function getOptions()
	{
		$options = array();

		foreach ($this->element->children() as $option)
		{
			// Only add <option /> elements.
			if ($option->getName() != 'option')
			{
				continue;
			}

			// Set up option elements.
			$tmp = new stdClass;
			$tmp->value = (string) $option['value'];
			$tmp->text = trim((string) $option);
			$tmp->disable = ((string) $option['disabled'] == 'true');
			$tmp->class = (string) $option['class'];
			$tmp->onclick = (string) $option['onclick'];

			// Add the option object to the result set.
			$options[] = $tmp;
		}

		reset($options);

		return $options;
	}
593360
public function getOptionParser()
    {
        $parser = parent::getOptionParser();
        $parser
            ->description(__d('eav', 'Select target table'))
            ->addOption('use', [
                'short' => 'u',
                'help' => __d('eav', 'The table alias name. e.g. "User.Users".'),
            ])
            ->addOption('action', [
                'short' => 'a',
                'help' => __d('eav', 'Indicates what you want to do, drop an existing column or add a new one.'),
                'default' => 'add',
                'choices' => ['add', 'drop'],
            ])
            ->addOption('name', [
                'short' => 'n',
                'help' => __d('eav', 'Name of the column to be added or dropped'),
            ])
            ->addOption('type', [
                'short' => 't',
                'help' => __d('eav', 'Type of information for the column being added.'),
                'default' => 'string',
                'choices' => EavToolbox::$types,
            ])
            ->addOption('bundle', [
                'short' => 'b',
                'help' => __d('eav', 'Indicates the column belongs to a bundle name within the table.'),
                'default' => null,
            ])
            ->addOption('searchable', [
                'short' => 's',
                'help' => __d('eav', 'Whether the column being created can be used in SQL WHERE clauses.'),
                'boolean' => true,
                'default' => true,
            ])
            ->addOption('overwrite', [
                'short' => 'o',
                'help' => __d('eav', 'Overwrite column definition if already exists. An exception will be raised when overwrite is disabled and column already exists.'),
                'boolean' => true,
            ]);

        return $parser;
    }
360753
public function getOptionParser()
    {
        $parser = parent::getOptionParser();

        return $parser->setDescription([
            'Asset Compress Shell',
            '',
            'Builds and clears assets defined in your asset_compress.ini',
            'file and in your view files.'
        ])->addSubcommand('clear', [
            'help' => 'Clears all builds defined in the ini file.'
        ])->addSubcommand('build', [
            'help' => 'Generate all builds defined in the ini files.'
        ])->addOption('force', [
            'help' => 'Force assets to rebuild. Ignores timestamp rules.',
            'short' => 'f',
            'boolean' => true
        ]);
    }
990196
public function getOptionParser()
    {
        $parser = parent::getOptionParser();

        $parser->addSubcommand('makedocs', [
            'description' => __('Crawl-generate fresh swagger file system documents for all entries found in the library.')
        ])
        ->addArgument('host', [
            'help' => __("Swagger host FQDN (without protocol) as to be inserted into the swagger doc property 'host'"),
            'required' => true
        ]);

        return $parser;
    }