X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fpsy%2Fpsysh%2Fsrc%2FPsy%2FCommand%2FHelpCommand.php;fp=vendor%2Fpsy%2Fpsysh%2Fsrc%2FPsy%2FCommand%2FHelpCommand.php;h=fd32ddefa694d8749589b3676db8991277362e39;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad
diff --git a/vendor/psy/psysh/src/Psy/Command/HelpCommand.php b/vendor/psy/psysh/src/Psy/Command/HelpCommand.php
new file mode 100644
index 000000000..fd32ddefa
--- /dev/null
+++ b/vendor/psy/psysh/src/Psy/Command/HelpCommand.php
@@ -0,0 +1,98 @@
+setName('help')
+ ->setAliases(array('?'))
+ ->setDefinition(array(
+ 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(array(
+ sprintf('%s', $name),
+ $command->getDescription(),
+ $aliases,
+ ));
+ }
+
+ $output->startPaging();
+ if ($table instanceof TableHelper) {
+ $table->render($output);
+ } else {
+ $table->render();
+ }
+ $output->stopPaging();
+ }
+ }
+}