/** * @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; }
/** * @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; }