think\console\Command::getSynopsis PHP Method

getSynopsis() public method

获取简介
public getSynopsis ( boolean $short = false ) : string
$short boolean 是否简单的
return string
    public function getSynopsis($short = false)
    {
        $key = $short ? 'short' : 'long';
        if (!isset($this->synopsis[$key])) {
            $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
        }
        return $this->synopsis[$key];
    }

Usage Example

Exemplo n.º 1
0
 /**
  * 描述指令
  * @param Command $command
  * @param array   $options
  * @return string|mixed
  */
 protected function describeCommand(Command $command, array $options = [])
 {
     $command->getSynopsis(true);
     $command->getSynopsis(false);
     $command->mergeConsoleDefinition(false);
     $this->writeText('<comment>Usage:</comment>', $options);
     foreach (array_merge([$command->getSynopsis(true)], $command->getAliases(), $command->getUsages()) as $usage) {
         $this->writeText("\n");
         $this->writeText('  ' . $usage, $options);
     }
     $this->writeText("\n");
     $definition = $command->getNativeDefinition();
     if ($definition->getOptions() || $definition->getArguments()) {
         $this->writeText("\n");
         $this->describeInputDefinition($definition, $options);
         $this->writeText("\n");
     }
     if ($help = $command->getProcessedHelp()) {
         $this->writeText("\n");
         $this->writeText('<comment>Help:</comment>', $options);
         $this->writeText("\n");
         $this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
         $this->writeText("\n");
     }
 }