/**
  * @inheritdoc
  */
 protected function describeApplication(ConsoleApplication $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         $width = $this->getColumnWidth($description->getCommands());
         $this->writeText($application->getHelp(), $options);
         $this->writeText("\n\n");
         if ($describedNamespace) {
             $this->writeText(sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText('<comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 $command = $description->getCommand($name);
                 $aliases = $command->getAliases();
                 if ($aliases && ApplicationDescription::GLOBAL_NAMESPACE === $namespace['id'] && in_array($name, $aliases)) {
                     // If the command has aliases, do not list it in the
                     // 'global' namespace. The aliases will be shown inline
                     // with the full command name.
                     continue;
                 }
                 // Colour local commands differently from remote ones.
                 $commandDescription = $command->getDescription();
                 if ($command instanceof PlatformCommand && !$command->isLocal()) {
                     $commandDescription = "<fg=cyan>{$commandDescription}</fg=cyan>";
                 }
                 $this->writeText("\n");
                 $this->writeText(sprintf("  %-{$width}s %s", "<info>{$name}</info>" . $this->formatAliases($aliases), $commandDescription), $options);
             }
         }
         $this->writeText("\n");
     }
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = [])
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         if ('' != ($help = $application->getHelp())) {
             $this->writeText("{$help}\n\n", $options);
         }
         $this->writeText("<comment>Usage:</comment>\n", $options);
         $this->writeText("  command [options] [arguments]\n\n", $options);
         $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
         $this->writeText("\n");
         $this->writeText("\n");
         $width = $this->getColumnWidth($description->getCommands());
         if ($describedNamespace) {
             $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if ($this->shouldListCommand($namespace['id']) === false) {
                 continue;
             }
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText(' <comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 if ($this->shouldListCommand($namespace['id'], $name) === false) {
                     continue;
                 }
                 $this->writeText("\n");
                 $spacingWidth = $width - strlen($name);
                 $this->writeText(sprintf('  <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         if ('' != ($help = $application->getHelp())) {
             $this->writeText("{$help}\n\n", $options);
         }
         $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
         $this->writeText("\n");
         $this->writeText("\n");
         $width = $this->getColumnWidth($description->getCommands());
         if ($describedNamespace) {
             $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText(' <comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 $command = $description->getCommand($name);
                 $aliases = $command->getAliases();
                 if ($aliases && in_array($name, $aliases)) {
                     // skip aliases
                     continue;
                 }
                 $this->writeText("\n");
                 $this->writeText(sprintf("  %-{$width}s %s", "<info>{$name}</info>" . $this->formatAliases($aliases), $command->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         if ('' != ($help = $application->getHelp())) {
             $this->writeText("{$help}\n\n", $options);
         }
         $this->writeText($application->trans('commands.list.messages.usage'), $options);
         $this->writeText($application->trans('commands.list.messages.usage_details'), $options);
         $options['application'] = $application;
         $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
         $this->writeText("\n");
         $this->writeText("\n");
         $width = $this->getColumnWidth($description->getCommands());
         if ($describedNamespace) {
             $this->writeText(sprintf($application->trans('commands.list.messages.comment'), $describedNamespace), $options);
         } else {
             $this->writeText($application->trans('commands.list.messages.available-commands'), $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText(' <comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 $this->writeText("\n");
                 $spacingWidth = $width - strlen($name);
                 $this->writeText(sprintf('  <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         if ('' != ($help = $application->getHelp())) {
             $this->writeText("{$help}\n\n", $options);
         }
         $this->writeText("<comment>Usage:</comment>\n", $options);
         $this->writeText(" [options] command [arguments]\n\n", $options);
         $this->writeText('<comment>Options:</comment>', $options);
         $inputOptions = $application->getDefinition()->getOptions();
         $width = 0;
         foreach ($inputOptions as $option) {
             $nameLength = strlen($option->getName()) + 2;
             if ($option->getShortcut()) {
                 $nameLength += strlen($option->getShortcut()) + 3;
             }
             $width = max($width, $nameLength);
         }
         ++$width;
         foreach ($inputOptions as $option) {
             $this->writeText("\n", $options);
             $this->describeInputOption($option, array_merge($options, array('name_width' => $width)));
         }
         $this->writeText("\n\n", $options);
         $width = $this->getColumnWidth($description->getCommands());
         if ($describedNamespace) {
             $this->writeText(sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText('<comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 $this->writeText("\n");
                 $this->writeText(sprintf(" <info>%-{$width}s</info> %s", $name, $description->getCommand($name)->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         $width = $this->getColumnWidth($description->getCommands());
         $this->writeText($application->getHelp(), $options);
         $this->writeText("\n\n");
         if ($describedNamespace) {
             $this->writeText(sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText('<comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 $this->writeText("\n");
                 $this->writeText(sprintf("  <info>%-{$width}s</info> %s", $name, $description->getCommand($name)->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }
Esempio n. 7
0
 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     $messages = array();
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $messages[] = sprintf("%-{$width}s %s", $command->getName(), $command->getDescription());
         }
     } else {
         $width = $this->getColumnWidth($description->getCommands());
         $messages[] = $application->getHelp();
         $messages[] = '';
         if ($describedNamespace) {
             $messages[] = sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace);
         } else {
             $messages[] = '<comment>Available commands:</comment>';
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $messages[] = '<comment>' . $namespace['id'] . '</comment>';
             }
             foreach ($namespace['commands'] as $name) {
                 $messages[] = sprintf("  <info>%-{$width}s</info> %s", $name, $description->getCommand($name)->getDescription());
             }
         }
     }
     $output = implode("\n", $messages);
     return isset($options['raw_text']) && $options['raw_text'] ? strip_tags($output) : $output;
 }
 /**
  * @inheritdoc
  */
 protected function describeApplication(ConsoleApplication $application, array $options = [])
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         $width = $this->getColumnWidth($description->getCommands());
         $this->writeText($application->getHelp(), $options);
         $this->writeText("\n\n");
         if ($describedNamespace) {
             $this->writeText(sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // Display commands grouped by namespace.
         foreach ($description->getNamespaces() as $namespace) {
             // Filter hidden commands in the namespace.
             /** @var Command[] $commands */
             $commands = [];
             foreach ($namespace['commands'] as $name) {
                 $command = $description->getCommand($name);
                 if (!$describedNamespace && $command instanceof CanHideInListInterface && $command->hideInList()) {
                     continue;
                 }
                 $commands[$name] = $command;
             }
             // Skip the namespace if it doesn't contain any commands.
             if (!count($commands)) {
                 continue;
             }
             // Display the namespace name.
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText('<comment>' . $namespace['id'] . '</comment>', $options);
             }
             // Display each command.
             foreach ($commands as $name => $command) {
                 $aliases = $command->getAliases();
                 if ($aliases && in_array($name, $aliases)) {
                     // If the command is an alias, do not list it in the
                     // 'global' namespace. The aliases will be shown inline
                     // with the full command name.
                     continue;
                 }
                 if ($command instanceof CommandBase) {
                     $aliases = $command->getVisibleAliases();
                 }
                 // Colour local commands differently from remote ones.
                 $commandDescription = $command->getDescription();
                 if ($command instanceof CommandBase && !$command->isLocal()) {
                     $commandDescription = "<fg=cyan>{$commandDescription}</fg=cyan>";
                 }
                 $this->writeText("\n");
                 $this->writeText(sprintf("  %-{$width}s %s", "<info>{$name}</info>" . $this->formatAliases($aliases), $commandDescription), $options);
             }
         }
         $this->writeText("\n");
     }
 }