protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (is_null($this->command)) {
         $this->command = $this->getApplication()->get($input->getArgument('command_name'));
     }
     $output->writeln($this->command->asText());
 }
Example #2
0
 /**
  * {@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('  <comment>Aliases:</comment> %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("    <info>%-{$width}s</info> %s%s", $name, $command->getDescription(), $aliases);
         }
         $messages = [];
         foreach ($categories as $name => $category) {
             $messages[] = '';
             $messages[] = sprintf('<comment>%s</comment>', OutputFormatter::escape($name));
             foreach ($category as $message) {
                 $messages[] = $message;
             }
         }
         $output->page($messages);
     }
 }
Example #3
0
 /**
  * Returns the text representation of the command.
  *
  * @return string The string that represents the command
  */
 public function asText()
 {
     $app = $this->getApplication()->getApp();
     $txt = $app['app.signature'] . "\n" . parent::asText();
     return $txt;
 }
Example #4
0
 public function asText()
 {
     return $this->innerCommand->asText();
 }