#!/usr/bin/env php
<?php
/**
 * The command router file of ZenTaoPHP.
 *
 * еrouterļwebʽrouterļһREQUESTֵֹͨġ
 *
 * ZenTaoPHP is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * ZenTaoPHP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with ZenTaoPHP.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @copyright   Copyright: 2009 Chunsheng Wang
 * @author      Chunsheng Wang <wwccss@263.net>
 * @package     ZenTaoPHP
 * @version     $Id$
 * @link        http://www.zentao.cn
 */
define('IN_SHELL', true);

/* ȡ */
if($argc != 2)
{
    echo 'Usage: ' . basename(__FILE__) . " <request>\n";
    echo <<<EOT
possiable requests:

# compress framwork class files to one file: 
$> call compress/compressFramework

# init a app directory.
$> call generator/initApp/app/\$appName

# create a module for a app.
$> call generator/createModule/app/\$appName/module/\$moduleName/table/\$tableName

EOT;
die();
}

/* ļ*/
chdir(dirname(__FILE__));
include '../../framework/router.class.php';
include '../../framework/control.class.php';
include '../../framework/model.class.php';
include '../../framework/helper.class.php';

/* ʵ·ɶ󣬲ãӵݿ⡣*/
$router = new router('cli');
$config = $router->loadConfig('common');

/* նʹõԡ*/
$router->setClientLang('en');
$lang = $router->loadLang('common');

/* ֹĸʽдݵĲֵ_SERVER['PATH_INFO']*/
putenv('PATH_INFO=' . trim($argv[1]));
$config->set('requestType', 'PATH_INFO');
$router->parseRequest();
$router->loadModule();
?>
