beginBlock() public method

Starts a new indented block.
public beginBlock ( ) : static
return static The current instance.
示例#1
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();
 }
示例#2
0
 /**
  * Renders the "Commands" section.
  *
  * @param BlockLayout       $layout   The layout.
  * @param CommandCollection $commands The commands to describe.
  */
 protected function renderCommands(BlockLayout $layout, CommandCollection $commands)
 {
     $layout->add(new Paragraph('<b>AVAILABLE COMMANDS</b>'));
     $layout->beginBlock();
     $commands = $commands->toArray();
     ksort($commands);
     foreach ($commands as $command) {
         $this->renderCommand($layout, $command);
     }
     $layout->endBlock();
     $layout->add(new EmptyLine());
 }
示例#3
0
 /**
  * Renders a list of global options.
  *
  * @param BlockLayout $layout  The layout.
  * @param Option[]    $options The global options to render.
  */
 protected function renderGlobalOptions(BlockLayout $layout, array $options)
 {
     $layout->add(new Paragraph('<b>GLOBAL OPTIONS</b>'));
     $layout->beginBlock();
     foreach ($options as $option) {
         $this->renderOption($layout, $option);
     }
     $layout->endBlock();
     $layout->add(new EmptyLine());
 }