Exemple #1
0
 /**
  * 获取command的usage信息
  * 
  * @param CommandInterface $command
  * @return string
  */
 protected function getCommandUsage(CommandInterface $command)
 {
     $argumentsUsages = [];
     foreach ($command->getDefinition()->getArguments() as $argument) {
         $usage = "<{$argument->getName()}>";
         if ($argument->isValueOptional()) {
             $usage = "[{$usage}]";
         }
         $argumentsUsages[] = $usage;
     }
     $usages[] = $command->getName();
     $options = $command->getDefinition()->getOptions();
     if ($haveOptions = !empty($options)) {
         $usages[] = '[options]';
     }
     if (!empty($argumentsUsages)) {
         if ($haveOptions) {
             $usages[] = '--';
         }
         $usages[] = implode(' ', $argumentsUsages);
     }
     return implode(' ', $usages);
 }
Exemple #2
0
 /**
  * 执行command
  * @param CommandInterface $command
  */
 function runCommand(CommandInterface $command)
 {
     $this->argv->bind($command->getDefinition()->merge($this->getDefaultDefinition()));
     return $command->execute($this->io, $this->argv);
 }