lithium\console\command\Help::run()

public method

Auto run the help command.

Parameters

  • string $command

    Name of the command to return help about.

Returns

boolean

Source

	public function run($command = null) {
		if (!$command) {
			$this->_renderCommands();
			return true;
		}

		if (!preg_match('/\\\\/', $command)) {
			$command = Inflector::camelize($command);
		}

		if (!$class = Libraries::locate('command', $command)) {
			$this->error("Command `{$command}` not found");
			return false;
		}

		if (strpos($command, '\\') !== false) {
			$command = join('', array_slice(explode("\\", $command), -1));
		}
		$command = strtolower(Inflector::slug($command));

		$run = null;
		$methods = $this->_methods($class);
		$properties = $this->_properties($class);
		$info = Inspector::info($class);

		$this->out('USAGE', 'heading');

		if (isset($methods['run'])) {
			$run = $methods['run'];
			unset($methods['run']);
			$this->_renderUsage($command, $run, $properties);
		}
		foreach ($methods as $method) {
			$this->_renderUsage($command, $method);
		}
		$this->out();

		if (!empty($info['description'])) {
			$this->nl();
			$this->_renderDescription($info);
			$this->nl();
		}

		if ($properties || $methods) {
			$this->out('OPTIONS', 'heading');
		}
		if ($run) {
			$this->_render($run['args']);
		}
		if ($methods) {
			$this->_render($methods);
		}
		if ($properties) {
			$this->_render($properties);
		}
		$this->out();
		return true;
	}