add cli mode

This commit is contained in:
joyqi
2017-05-09 17:38:09 +08:00
parent b3ce12c575
commit 16a74d5cc9
3 changed files with 128 additions and 1 deletions
+10
View File
@@ -23,6 +23,10 @@ class Widget_Init extends Typecho_Widget
*/
public function execute()
{
if (php_sapi_name() == 'cli') {
define('__TYPECHO_CLI__', true);
}
/** 对变量赋值 */
$options = $this->widget('Widget_Options');
@@ -32,6 +36,12 @@ class Widget_Init extends Typecho_Widget
Typecho_I18n::setLang($dir . '/' . $options->lang . '.mo');
}
/** 进入命令行格式 */
if (defined('__TYPECHO_CLI__')) {
new CLI();
exit(0);
}
/** cookie初始化 */
Typecho_Cookie::setPrefix($options->rootUrl);