Webmozart\Console\Api\Command\Command::getDefaultSubCommands PHP Method

getDefaultSubCommands() public method

Returns the commands that should be executed if no explicit command is passed.
public getDefaultSubCommands ( ) : CommandCollection
return CommandCollection The default commands.
    public function getDefaultSubCommands()
    {
        return $this->defaultSubCommands;
    }

Usage Example

コード例 #1
0
ファイル: CommandHelp.php プロジェクト: webmozart/console
 /**
  * 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());
 }
All Usage Examples Of Webmozart\Console\Api\Command\Command::getDefaultSubCommands