getName() public method

Returns the name of the command.
public getName ( ) : string
return string The name of the command.
Esempio 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);
 }
Esempio n. 2
0
 /**
  * Renders a command in the "Commands" section.
  *
  * @param BlockLayout $layout  The layout.
  * @param Command     $command The command to describe.
  */
 protected function renderCommand(BlockLayout $layout, Command $command)
 {
     $description = $command->getConfig()->getDescription();
     $name = '<c1>' . $command->getName() . '</c1>';
     $layout->add(new LabeledParagraph($name, $description));
 }
Esempio n. 3
0
 /**
  * Renders a sub-command in the "Commands" section.
  *
  * @param BlockLayout $layout  The layout.
  * @param Command     $command The command to render.
  */
 protected function renderSubCommand(BlockLayout $layout, Command $command)
 {
     $config = $command->getConfig();
     $description = $config->getDescription();
     $help = $config->getHelp();
     $arguments = $command->getArgsFormat()->getArguments(false);
     $options = $command->getArgsFormat()->getOptions(false);
     if ($config instanceof OptionCommandConfig) {
         if ($config->isLongNamePreferred()) {
             $preferredName = '--<u>' . $config->getLongName() . '</u>';
             $alternativeName = $config->getShortName() ? '-<u>' . $config->getShortName() . '</u>' : null;
         } else {
             $preferredName = '-<u>' . $config->getShortName() . '</u>';
             $alternativeName = '--<u>' . $config->getLongName() . '</u>';
         }
         $name = $preferredName;
         if ($alternativeName) {
             $name .= ' (' . $alternativeName . ')';
         }
     } else {
         $name = '<u>' . $command->getName() . '</u>';
     }
     $layout->add(new Paragraph($name));
     $layout->beginBlock();
     if ($description) {
         $this->renderSubCommandDescription($layout, $description);
     }
     if ($help) {
         $this->renderSubCommandHelp($layout, $help);
     }
     if ($arguments) {
         $this->renderSubCommandArguments($layout, $arguments);
     }
     if ($options) {
         $this->renderSubCommandOptions($layout, $options);
     }
     if (!$description && !$help && !$arguments && !$options) {
         $layout->add(new EmptyLine());
     }
     $layout->endBlock();
 }