#!/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: 
ļѹΪһļܡ

$> ztphp compress/compressFramework

init a app. (You can set the ZT_APP_ROOT env variable if the application in other directory.)
for example: export ZT_APP_ROOT=/home/wwccss/app (under linux)
note: If you set ZT_APP_ROOT, it should be absolute path.

ʼһӦá(ZT_APP_ROOTָӦڵĸĿ¼ӦúͿܵĿ¼ǷĻ)
linux棺 export ZT_APP_ROOT=/home/wwccss/app
ע⣺ZT_APP_ROOTӦǾ·

$> ztphp generator/createApp/\$appName/

create a module for a app. need appName, moduleName and tableanme.
һģ飬ҪָappName, moduleNameԼģӦtableName.

$> ztphp generator/createModule/\$appName/\$moduleName/\$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';

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

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

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