From aa3fc923b49c9f5c60ab86802a032e57be607d8d Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Dec 2017 20:29:20 -0500 Subject: [PATCH] Re-remove HelpShell. It has been replaced by HelpCommand in 3.next. --- src/Shell/HelpShell.php | 172 ---------------------------------------- 1 file changed, 172 deletions(-) delete mode 100644 src/Shell/HelpShell.php diff --git a/src/Shell/HelpShell.php b/src/Shell/HelpShell.php deleted file mode 100644 index babc5cf0c8b..00000000000 --- a/src/Shell/HelpShell.php +++ /dev/null @@ -1,172 +0,0 @@ -param('xml')) { - parent::startup(); - } - } - - /** - * {@inheritDoc} - */ - public function setCommandCollection(CommandCollection $commands) - { - $this->commands = $commands; - } - - /** - * Main function Prints out the list of shells. - * - * @return void - */ - public function main() - { - if (!$this->param('xml')) { - $this->out('Current Paths:', 2); - $this->out('* app: ' . APP_DIR); - $this->out('* root: ' . rtrim(ROOT, DIRECTORY_SEPARATOR)); - $this->out('* core: ' . rtrim(CORE_PATH, DIRECTORY_SEPARATOR)); - $this->out(''); - - $this->out('Available Commands:', 2); - } - - if (!$this->commands) { - $this->commands = new CommandCollection($this->getCommands()); - } - - $commands = $this->commands->getIterator(); - $commands->ksort(); - $commands = new CommandCollection((array)$commands); - - if ($this->param('xml')) { - $this->asXml($commands); - - return; - } - $this->asText($commands); - } - - /** - * Get the list of commands using the CommandTask - * - * Provides backwards compatibility when an application doesn't use - * CommandRunner. - * - * @return array - */ - protected function getCommands() - { - $task = new CommandTask($this->getIo()); - $nested = $task->getShellList(); - $out = []; - foreach ($nested as $section => $commands) { - $prefix = ''; - if ($section !== 'CORE' && $section !== 'app') { - $prefix = Inflector::underscore($section) . '.'; - } - foreach ($commands as $command) { - $out[$prefix . $command] = $command; - } - } - - return $out; - } - - /** - * Output text. - * - * @param \Cake\Console\CommandCollection $commands The command collection to output. - * @return void - */ - protected function asText($commands) - { - foreach ($commands as $name => $class) { - $this->out('- ' . $name); - } - $this->out(''); - - $this->out('To run a command, type `cake shell_name [args|options]`'); - $this->out('To get help on a specific command, type `cake shell_name --help`', 2); - } - - /** - * Output as XML - * - * @param \Cake\Console\CommandCollection $commands The command collection to output - * @return void - */ - protected function asXml($commands) - { - $shells = new SimpleXMLElement(''); - foreach ($commands as $name => $class) { - $shell = $shells->addChild('shell'); - $shell->addAttribute('name', $name); - $shell->addAttribute('call_as', $name); - $shell->addAttribute('provider', $class); - $shell->addAttribute('help', $name . ' -h'); - } - $this->_io->setOutputAs(ConsoleOutput::RAW); - $this->out($shells->saveXML()); - } - - /** - * Gets the option parser instance and configures it. - * - * @return \Cake\Console\ConsoleOptionParser - */ - public function getOptionParser() - { - $parser = parent::getOptionParser(); - - $parser->setDescription( - 'Get the list of available shells for this application.' - )->addOption('xml', [ - 'help' => 'Get the listing as XML.', - 'boolean' => true - ]); - - return $parser; - } -}