X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fpsy%2Fpsysh%2Fsrc%2FCommand%2FHelpCommand.php;fp=vendor%2Fpsy%2Fpsysh%2Fsrc%2FCommand%2FHelpCommand.php;h=a50f2562451ef51fb9f61a8abd42cb6a0fa85648;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0
diff --git a/vendor/psy/psysh/src/Command/HelpCommand.php b/vendor/psy/psysh/src/Command/HelpCommand.php
new file mode 100644
index 000000000..a50f25624
--- /dev/null
+++ b/vendor/psy/psysh/src/Command/HelpCommand.php
@@ -0,0 +1,98 @@
+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].')
+ ->setHelp('My. How meta.');
+ }
+
+ /**
+ * Helper for setting a subcommand to retrieve help for.
+ *
+ * @param Command $command
+ */
+ public function setCommand($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 {
+ // list available commands
+ $commands = $this->getApplication()->all();
+
+ $table = $this->getTable($output);
+
+ foreach ($commands as $name => $command) {
+ if ($name !== $command->getName()) {
+ continue;
+ }
+
+ if ($command->getAliases()) {
+ $aliases = sprintf('Aliases: %s', implode(', ', $command->getAliases()));
+ } else {
+ $aliases = '';
+ }
+
+ $table->addRow([
+ sprintf('%s', $name),
+ $command->getDescription(),
+ $aliases,
+ ]);
+ }
+
+ $output->startPaging();
+ if ($table instanceof TableHelper) {
+ $table->render($output);
+ } else {
+ $table->render();
+ }
+ $output->stopPaging();
+ }
+ }
+}