getAliases() public method

Returns the aliases for the command.
public getAliases ( ) : array
return array An array of aliases for the command
 /**
  * {@inheritdoc}
  */
 protected function describeCommand(Command $command, array $options = array())
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $markdown = $command->getName() . "\n" . str_repeat('-', strlen($command->getName())) . "\n\n" . '* Description: ' . ($command->getDescription() ?: '<none>') . "\n" . '* Usage: `' . $command->getSynopsis() . '`' . "\n" . '* Aliases: ' . (count($command->getAliases()) ? '`' . implode('`, `', $command->getAliases()) . '`' : '<none>');
     if ($help = $command->getProcessedHelp()) {
         $markdown .= "\n\n" . $help;
     }
     if ($definitionMarkdown = $this->describeInputDefinition($command->getNativeDefinition())) {
         $markdown .= "\n\n" . $definitionMarkdown;
     }
     return $markdown;
 }
Example #2
0
 protected function describeCommand(Command $command, array $options = array())
 {
     $command->getSynopsis(true);
     $command->getSynopsis(false);
     $command->mergeApplicationDefinition(false);
     $this->writeText('<comment>Usage:</comment>', $options);
     foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
         $this->writeText("\n");
         $this->writeText('  ' . $usage, $options);
     }
     $this->writeText("\n");
     $definition = $command->getNativeDefinition();
     if ($definition->getOptions() || $definition->getArguments()) {
         $this->writeText("\n");
         $this->describeInputDefinition($definition, $options);
         $this->writeText("\n");
     }
     if ($help = $command->getProcessedHelp()) {
         $this->writeText("\n");
         $this->writeText('<comment>Help:</comment>', $options);
         $this->writeText("\n");
         $this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
         $this->writeText("\n");
     }
 }
 /**
  * @inheritdoc
  */
 protected function describeCommand(Command $command, array $options = [])
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $this->write($command->getName() . "\n" . str_repeat('-', strlen($command->getName())) . "\n");
     if ($description = $command->getDescription()) {
         $this->write("{$description}\n\n");
     }
     $aliases = $command instanceof CommandBase ? $command->getVisibleAliases() : $command->getAliases();
     if ($aliases) {
         $this->write('Aliases: ' . '`' . implode('`, `', $aliases) . '`' . "\n\n");
     }
     $executableName = 'platform';
     $this->write("## Usage:\n\n```\n{$executableName} " . $command->getSynopsis() . "\n```\n\n");
     if ($help = $command->getProcessedHelp()) {
         $this->write($help);
         $this->write("\n\n");
     }
     if ($command->getNativeDefinition()) {
         $this->describeInputDefinition($command->getNativeDefinition());
         $this->write("\n\n");
     }
     if ($command instanceof CommandBase && ($examples = $command->getExamples())) {
         $this->write('## Examples');
         $this->write("\n");
         $name = $command->getName();
         foreach ($examples as $arguments => $description) {
             $this->write("\n* {$description}:  \n  ```\n  platform {$name} {$arguments}\n  ```\n");
         }
         $this->write("\n");
     }
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 protected function describeCommand(Command $command, array $options = array())
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $messages = array('<comment>Usage:</comment>', ' ' . $command->getSynopsis(), '');
     if ($command->getAliases()) {
         $messages[] = '<comment>Aliases:</comment> <info>' . implode(', ', $command->getAliases()) . '</info>';
     }
     $messages[] = $this->describeInputDefinition($command->getNativeDefinition());
     if ($help = $command->getProcessedHelp()) {
         $messages[] = '<comment>Help:</comment>';
         $messages[] = ' ' . str_replace("\n", "\n ", $help) . "\n";
     }
     $output = implode("\n", $messages);
     return isset($options['raw_text']) && $options['raw_text'] ? strip_tags($output) : $output;
 }
 /**
  * @inheritdoc
  */
 protected function describeCommand(Command $command, array $options = array())
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $this->writeText("<comment>Command:</comment> " . $command->getName(), $options);
     if ($aliases = $command->getAliases()) {
         $this->writeText("\n");
         $this->writeText('<comment>Aliases:</comment> ' . implode(', ', $aliases), $options);
     }
     if ($description = $command->getDescription()) {
         $this->writeText("\n");
         $this->writeText("<comment>Description:</comment> {$description}", $options);
     }
     $this->writeText("\n\n");
     $this->writeText('<comment>Usage:</comment>', $options);
     $this->writeText("\n");
     $this->writeText(' ' . $command->getSynopsis(), $options);
     $this->writeText("\n");
     if ($definition = $command->getNativeDefinition()) {
         $this->writeText("\n");
         $this->describeInputDefinition($definition, $options);
     }
     if ($help = $command->getProcessedHelp()) {
         $this->writeText("\n");
         $this->writeText('<comment>Help:</comment>', $options);
         $this->writeText("\n");
         $this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
         $this->writeText("\n");
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function describeCommand(Command $command, array $options = array())
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $this->write($command->getName() . "\n" . str_repeat('-', strlen($command->getName())) . "\n\n" . '* Description: ' . ($command->getDescription() ?: '<none>') . "\n" . '* Usage:' . "\n\n" . array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
         return $carry .= '  * `' . $usage . '`' . "\n";
     }));
     if ($help = $command->getProcessedHelp()) {
         $this->write("\n");
         $this->write($help);
     }
     if ($command->getNativeDefinition()) {
         $this->write("\n\n");
         $this->describeInputDefinition($command->getNativeDefinition());
     }
 }
Example #7
0
 /**
  * @param Command $command
  *
  * @return \DOMDocument
  */
 public function getCommandDocument(Command $command)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($commandXML = $dom->createElement('command'));
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $commandXML->setAttribute('id', $command->getName());
     $commandXML->setAttribute('name', $command->getName());
     $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
     foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
         $usagesXML->appendChild($dom->createElement('usage', $usage));
     }
     $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
     $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
     $commandXML->appendChild($helpXML = $dom->createElement('help'));
     $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
     $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
     $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
     return $dom;
 }
 /**
  * @inheritdoc
  */
 protected function describeCommand(Command $command, array $options = [])
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $this->writeText("<comment>Command:</comment> " . $command->getName(), $options);
     $aliases = $command instanceof CommandBase ? $command->getVisibleAliases() : $command->getAliases();
     if ($aliases) {
         $this->writeText("\n");
         $this->writeText('<comment>Aliases:</comment> ' . implode(', ', $aliases), $options);
     }
     if ($description = $command->getDescription()) {
         $this->writeText("\n");
         $this->writeText("<comment>Description:</comment> {$description}", $options);
     }
     $this->writeText("\n\n");
     $this->writeText('<comment>Usage:</comment>', $options);
     $this->writeText("\n");
     $executableName = 'platform';
     $this->writeText(' ' . $executableName . ' ' . $command->getSynopsis(), $options);
     $this->writeText("\n");
     if ($definition = $command->getNativeDefinition()) {
         $this->writeText("\n");
         $this->describeInputDefinition($definition, $options);
         $this->writeText("\n");
     }
     if ($help = $command->getProcessedHelp()) {
         $this->writeText("\n");
         $this->writeText('<comment>Help:</comment>', $options);
         $this->writeText("\n");
         $this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
         $this->writeText("\n");
     }
     if ($command instanceof CommandBase && ($examples = $command->getExamples())) {
         $this->writeText("\n");
         $this->writeText('<comment>Examples:</comment>', $options);
         $name = $command->getName();
         foreach ($examples as $arguments => $description) {
             $this->writeText("\n {$description}:\n   <info>platform {$name} {$arguments}</info>\n");
         }
     }
 }
Example #9
0
 /**
  * Adds a command object.
  *
  * If a command with the same name already exists, it will be overridden.
  *
  * @param Command $command A Command object
  *
  * @return Command The registered command
  *
  * @api
  */
 public function add(Command $command)
 {
     $command->setApplication($this);
     if (!$command->isEnabled()) {
         $command->setApplication(null);
         return;
     }
     $this->commands[$command->getName()] = $command;
     foreach ($command->getAliases() as $alias) {
         $this->commands[$alias] = $command;
     }
     return $command;
 }
 /**
  * {@inheritdoc}
  */
 protected function describeCommand(Command $command, array $options = array())
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     return $this->output(array('name' => $command->getName(), 'usage' => $command->getSynopsis(), 'description' => $command->getDescription(), 'help' => $command->getProcessedHelp(), 'aliases' => $command->getAliases(), 'definition' => $this->describeInputDefinition($command->getNativeDefinition(), array('as_array' => true))), $options);
 }
Example #11
0
 /**
  * @param Command $command
  *
  * @return array
  */
 private function getCommandData(Command $command)
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     return array('name' => $command->getName(), 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()), 'description' => $command->getDescription(), 'help' => $command->getProcessedHelp(), 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()));
 }
Example #12
0
 /**
  * @param \Symfony\Component\Console\Command\Command $command
  */
 protected function registerConfigCommandAlias(Command $command)
 {
     if ($this->hasConfigCommandAliases()) {
         foreach ($this->config['commands']['aliases'] as $alias) {
             if (!is_array($alias)) {
                 continue;
             }
             $aliasCommandName = key($alias);
             $commandString = $alias[$aliasCommandName];
             list($originalCommand) = explode(' ', $commandString);
             if ($command->getName() == $originalCommand) {
                 $currentCommandAliases = $command->getAliases();
                 $currentCommandAliases[] = $aliasCommandName;
                 $command->setAliases($currentCommandAliases);
             }
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getAliases()
 {
     return $this->decoratedCommand->getAliases();
 }
Example #14
0
 public function getAliases()
 {
     return $this->innerCommand->getAliases();
 }
Example #15
0
 protected function describeCommand(Command $command, array $options = array())
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($commandXML = $dom->createElement('command'));
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $commandXML->setAttribute('id', $command->getName());
     $commandXML->setAttribute('name', $command->getName());
     $commandXML->appendChild($usageXML = $dom->createElement('usage'));
     $usageXML->appendChild($dom->createTextNode(sprintf($command->getSynopsis(), '')));
     $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
     $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
     $commandXML->appendChild($helpXML = $dom->createElement('help'));
     $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
     $commandXML->appendChild($aliasesXML = $dom->createElement('aliases'));
     foreach ($command->getAliases() as $alias) {
         $aliasesXML->appendChild($aliasXML = $dom->createElement('alias'));
         $aliasXML->appendChild($dom->createTextNode($alias));
     }
     $definitionXML = $this->describeInputDefinition($command->getNativeDefinition(), array('as_dom' => true));
     $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
     return $this->output($dom, $options);
 }
Example #16
0
 /**
  * Adds a command object.
  *
  * If a command with the same name already exists, it will be overridden.
  *
  * @param Command $command A Command object
  *
  * @return Command The registered command
  *
  * @api
  */
 public function add(Command $command)
 {
     $command->setApplication($this);
     $this->commands[$command->getName()] = $command;
     foreach ($command->getAliases() as $alias) {
         $this->commands[$alias] = $command;
     }
     return $command;
 }
Example #17
0
 /**
  * Formats command aliases to show them in the command description.
  *
  * @param Command $command
  *
  * @return string
  */
 private function getCommandAliasesText($command)
 {
     $text = '';
     $aliases = $command->getAliases();
     if ($aliases) {
         $text = '[' . implode('|', $aliases) . '] ';
     }
     return $text;
 }
Example #18
0
 /**
  * @param Command $command
  */
 public function registerConfigCommandAlias(Command $command)
 {
     foreach ($this->getArray(array('commands', 'aliases')) as $alias) {
         if (!is_array($alias)) {
             continue;
         }
         $aliasCommandName = key($alias);
         $commandString = $alias[$aliasCommandName];
         list($originalCommand) = explode(' ', $commandString, 2);
         if ($command->getName() !== $originalCommand) {
             continue;
         }
         $command->setAliases(array_merge($command->getAliases(), array($aliasCommandName)));
     }
 }