X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fdrush%2Fdrush%2Fsrc%2FPsysh%2FDrushHelpCommand.php;fp=vendor%2Fdrush%2Fdrush%2Fsrc%2FPsysh%2FDrushHelpCommand.php;h=fb3f0a11c34086de8b68c9be70ff92161b438185;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=0000000000000000000000000000000000000000;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website
diff --git a/vendor/drush/drush/src/Psysh/DrushHelpCommand.php b/vendor/drush/drush/src/Psysh/DrushHelpCommand.php
new file mode 100644
index 000000000..fb3f0a11c
--- /dev/null
+++ b/vendor/drush/drush/src/Psysh/DrushHelpCommand.php
@@ -0,0 +1,128 @@
+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 {
+ $namespaces = [];
+
+ // 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 = '';
+ }
+
+ $namespace = '';
+ if ($command instanceof DrushCommand) {
+ $namespace = $command->getNamespace();
+ }
+
+ if (empty($namespace)) {
+ $namespace = static::PSYSH_CATEGORY;
+ }
+
+ if (!isset($namespaces[$namespace])) {
+ $namespaces[$namespace] = [];
+ }
+
+ $namespaces[$namespace][] = sprintf(" %-${width}s %s%s", $name, $command->getDescription(), $aliases);
+ }
+
+ $messages = [];
+
+ foreach ($namespaces as $namespace => $command_messages) {
+ $messages[] = '';
+ $messages[] = sprintf('%s', OutputFormatter::escape($namespace));
+ foreach ($command_messages as $command_message) {
+ $messages[] = $command_message;
+ }
+ }
+
+ $output->page($messages);
+ }
+ }
+}