getAliases() public method

Returns the alias names of the command.
public getAliases ( ) : string[]
return string[] An array of alias names of the command.
Ejemplo n.º 1
0
 /**
  * Adds a command to the collection.
  *
  * If a command exists with the same name in the collection, that command
  * is overwritten.
  *
  * @param Command $command The command to add.
  *
  * @see merge(), replace()
  */
 public function add(Command $command)
 {
     $name = $command->getName();
     $this->commands[$name] = $command;
     if ($shortName = $command->getShortName()) {
         $this->shortNameIndex[$shortName] = $name;
     }
     foreach ($command->getAliases() as $alias) {
         $this->aliasIndex[$alias] = $name;
     }
     ksort($this->aliasIndex);
 }
Ejemplo n.º 2
0
 /**
  * Renders the "Usage" section.
  *
  * @param BlockLayout $layout  The layout.
  * @param Command     $command The command to render.
  */
 protected function renderUsage(BlockLayout $layout, Command $command)
 {
     $formatsToPrint = array();
     // Start with the default commands
     if ($command->hasDefaultSubCommands()) {
         // If the command has default commands, print them
         foreach ($command->getDefaultSubCommands() as $subCommand) {
             // The name of the sub command is only optional (i.e. printed
             // wrapped in brackets: "[sub]") if the command is not
             // anonymous
             $nameOptional = !$subCommand->getConfig()->isAnonymous();
             $formatsToPrint[] = array($subCommand->getArgsFormat(), $nameOptional);
         }
     } else {
         // Otherwise print the command's usage itself
         $formatsToPrint[] = array($command->getArgsFormat(), false);
     }
     // Add remaining sub-commands
     foreach ($command->getSubCommands() as $subCommand) {
         // Don't duplicate default commands
         if (!$subCommand->getConfig()->isDefault()) {
             $formatsToPrint[$subCommand->getName()] = array($subCommand->getArgsFormat(), false);
         }
     }
     $appName = $command->getApplication()->getConfig()->getName();
     $prefix = count($formatsToPrint) > 1 ? '    ' : '';
     $layout->add(new Paragraph('<b>USAGE</b>'));
     $layout->beginBlock();
     foreach ($formatsToPrint as $vars) {
         $this->renderSynopsis($layout, $vars[0], $appName, $prefix, $vars[1]);
         $prefix = 'or: ';
     }
     if ($command->hasAliases()) {
         $layout->add(new EmptyLine());
         $this->renderAliases($layout, $command->getAliases());
     }
     $layout->endBlock();
     $layout->add(new EmptyLine());
 }