#!/usr/bin/php -q #li3 > Lithium Documentation > app/controllers/CommandController::command()

Source

						public function command() {
		extract(Message::aliases());

		$default = array(
			'status' => 'success',
			'data' => array(
				'text' => array(
					$t('lithium: ``: command not found.')
				)
			)
		);
		$params = null;
		$method = 'help';

		if (!empty($this->request->query['cmd'])) {
			$params = explode(' ', $this->request->query['cmd']);
			$method = $params[0];
			unset($params[0]);
			$params = array_values($params);
		}

		$isLink = (
			!empty($this->_links[$method]) &&
			(empty($params) || !is_callable(array($this, '_' . $method)))
		);

		switch (true) {
			case !empty($isLink) :
				$output = $this->_url($this->_links[$method]);
			break;
			case is_callable(array($this, '_' . $method)):
				$output = $this->invokeMethod('_' . $method, $params);
			break;
			default:
				$suggestion = array(
					$t('lithium `{:method}`: command not found.', compact('method')),
					'***',
					$t('If you like to search the lithium network, try `search {:command}`', array(
						'command' => $_GET['cmd']
					))
				);
				$output = $this->_text($suggestion);
			break;
		}
		$response = array('data' => $output) + $default;
		return 'RadCli.response(' . json_encode($response) . ')';
	}