/** * 显示帮助信息 * * @param string $className * @param WindException $e */ protected function help($className, $e = null) { $helps = array(); $helps[10] = 'usage: command [options] [args]'; $helps[11] = 'Valid options:'; $helps[12] = $this->handlerAdapter->getModuleKey() . ' routing information,the name of application module'; $helps[13] = $this->handlerAdapter->getControllerKey() . ' routing information,the name of controller'; $helps[14] = $this->handlerAdapter->getActionKey() . ' routing information,the name of action'; $helps[15] = $this->handlerAdapter->getParamKey() . ' the parameters of the method [action]'; if (class_exists($className)) { /* @var $handler WindCommandController */ $handler = new $className(); $action = $this->handlerAdapter->getAction(); if ($action !== 'run') { $action = $handler->resolvedActionName($this->handlerAdapter->getAction()); } if (!method_exists($handler, $action)) { return; } $method = new ReflectionMethod($handler, $action); $helps[20] = "\r\nlist -p [paraments] of '{$className}::{$action}' \r\n"; $method = $method->getParameters(); $i = 21; foreach ($method as $value) { $helps[$i++] = $value; } } if ($e !== null) { $helps[0] = $e->getMessage() . "\r\n"; } exit(implode("\r\n", $helps)); }
/** * @param WindErrorMessage|string $error 异常描述或者错误处理类 * @param int $code 错误码 */ public function __construct($error, $code = 0) { if ($error instanceof WindErrorMessage) { $this->setError($error); parent::__construct($error->getError(0), $code); } else { parent::__construct($error, $code); } }