/** * Generate the usage for a shell based on its arguments and options. * Usage strings favor short options over the long ones. and optional args will * be indicated with [] * * @return string */ protected function _generateUsage() { $usage = ['cake ' . $this->_parser->command()]; $subcommands = $this->_parser->subcommands(); if (!empty($subcommands)) { $usage[] = '[subcommand]'; } $options = []; foreach ($this->_parser->options() as $option) { $options[] = $option->usage(); } if (count($options) > $this->_maxOptions) { $options = ['[options]']; } $usage = array_merge($usage, $options); $args = []; foreach ($this->_parser->arguments() as $argument) { $args[] = $argument->usage(); } if (count($args) > $this->_maxArgs) { $args = ['[arguments]']; } $usage = array_merge($usage, $args); return implode(' ', $usage); }