getConfig() публичный Метод

Returns the configuration of the command.
public getConfig ( ) : CommandConfig
Результат Webmozart\Console\Api\Config\CommandConfig The command configuration.
Пример #1
0
 public function testCreate()
 {
     $config = new CommandConfig('command');
     $config->addArgument('argument');
     $config->addOption('option', 'o');
     $command = new Command($config, $this->application);
     $this->assertSame($config, $command->getConfig());
     $this->assertSame($this->application, $command->getApplication());
     $argsFormat = $command->getArgsFormat();
     $this->assertNull($argsFormat->getBaseFormat());
     $this->assertCount(1, $argsFormat->getArguments());
     $this->assertTrue($argsFormat->hasArgument('argument'));
     $this->assertCount(1, $argsFormat->getOptions());
     $this->assertTrue($argsFormat->hasOption('option'));
 }
Пример #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));
 }
Пример #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();
 }