Exemple #1
0
 /**
  * 获取command的Help对象
  * 
  * @param CommandInterface $command
  * @return \Slince\Console\Help
  */
 function getCommandHelp(CommandInterface $command)
 {
     $help = $this->createHelp();
     $help->setDescription($command->getDescription());
     $optionHelps = $argumentHelps = [];
     foreach ($command->getDefinition()->getArguments() as $argument) {
         $argumentHelps[$argument->getName()] = $argument->getDescription();
     }
     foreach ($command->getDefinition()->getOptions() as $option) {
         $key = ($option->isShort() ? '-' : '--') . $option->getName();
         $optionHelps[$key] = $option->getDescription();
     }
     $help->setUsage($this->getCommandUsage($command));
     $help->setArgumentHelps($argumentHelps);
     $help->setOptionHelps($optionHelps);
     return $help;
 }