X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fdrush%2Fdrush%2Flib%2FDrush%2FPsysh%2FDrushHelpCommand.php;fp=vendor%2Fdrush%2Fdrush%2Flib%2FDrush%2FPsysh%2FDrushHelpCommand.php;h=9a3961f13c9dbd4d3e16fc3f2d9b0bebc3579246;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/vendor/drush/drush/lib/Drush/Psysh/DrushHelpCommand.php b/vendor/drush/drush/lib/Drush/Psysh/DrushHelpCommand.php new file mode 100644 index 000000000..9a3961f13 --- /dev/null +++ b/vendor/drush/drush/lib/Drush/Psysh/DrushHelpCommand.php @@ -0,0 +1,126 @@ +setName('help') + ->setAliases(['?']) + ->setDefinition([ + new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', NULL), + ]) + ->setDescription('Show a list of commands. Type `help [foo]` for information about [foo].'); + } + + /** + * Helper for setting a subcommand to retrieve help for. + * + * @param \Symfony\Component\Console\Command\Command $command + */ + public function setCommand(Command $command) { + $this->command = $command; + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) { + if ($this->command !== NULL) { + // Help for an individual command. + $output->page($this->command->asText()); + $this->command = NULL; + } + elseif ($name = $input->getArgument('command_name')) { + // Help for an individual command. + $output->page($this->getApplication()->get($name)->asText()); + } + else { + $categories = []; + + // List available commands. + $commands = $this->getApplication()->all(); + + // Find the alignment width. + $width = 0; + foreach ($commands as $command) { + $width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width; + } + $width += 2; + + foreach ($commands as $name => $command) { + if ($name !== $command->getName()) { + continue; + } + + if ($command->getAliases()) { + $aliases = sprintf(' Aliases: %s', implode(', ', $command->getAliases())); + } + else { + $aliases = ''; + } + + if ($command instanceof DrushCommand) { + $category = (string) $command->getCategory(); + } + else { + $category = static::PSYSH_CATEGORY; + } + + if (!isset($categories[$category])) { + $categories[$category] = []; + } + + $categories[$category][] = sprintf(" %-${width}s %s%s", $name, $command->getDescription(), $aliases); + } + + $messages = []; + + foreach ($categories as $name => $category) { + $messages[] = ''; + $messages[] = sprintf('%s', OutputFormatter::escape($name)); + foreach ($category as $message) { + $messages[] = $message; + } + } + + $output->page($messages); + } + } + +}