コード例 #1
0
ファイル: Command.php プロジェクト: cargomedia/cm
 /**
  * @return string
  */
 public function getHelp()
 {
     $helpText = $this->getName();
     foreach (CM_Cli_Arguments::getNumericForMethod($this->_method) as $paramString) {
         $helpText .= ' ' . $paramString;
     }
     foreach (CM_Cli_Arguments::getNamedForMethod($this->_method) as $paramString) {
         $helpText .= ' [' . $paramString . ']';
     }
     return $helpText;
 }
コード例 #2
0
ファイル: CommandManager.php プロジェクト: NicolasSchmutz/cm
 /**
  * @param string|null $packageName
  * @throws CM_Cli_Exception_InvalidArguments
  * @return string
  */
 public function getHelp($packageName = null)
 {
     $helpHeader = '';
     $helpHeader .= 'Usage:' . PHP_EOL;
     $helpHeader .= ' [options] <command> [arguments]' . PHP_EOL;
     $helpHeader .= PHP_EOL;
     $helpHeader .= 'Options:' . PHP_EOL;
     $reflectionMethod = new ReflectionMethod($this, 'configure');
     foreach (CM_Cli_Arguments::getNamedForMethod($reflectionMethod) as $paramString) {
         $helpHeader .= ' ' . $paramString . PHP_EOL;
     }
     $helpHeader .= PHP_EOL;
     $helpHeader .= 'Commands:' . PHP_EOL;
     $help = '';
     $commands = $this->getCommands();
     foreach ($commands as $command) {
         if (!$command->isAbstract() && (!$packageName || $packageName === $command->getPackageName())) {
             $help .= ' ' . $command->getHelp() . PHP_EOL;
         }
     }
     if ($packageName && !$help) {
         throw new CM_Cli_Exception_InvalidArguments('Package `' . $packageName . '` not found.');
     }
     return $helpHeader . $help;
 }