-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.php
80 lines (72 loc) · 2.06 KB
/
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* Created by JiangJiaCai.
* User: Administrator
* Date: 2017/8/23 0023
* Time: 13:28
*/
/**
* tool run main file
* Commond list
* - build build these annotation to target dir ,load these files in runtime
* - help show help document
* - clean remove build dir and every build file
*/
define('COM_JJCBS_ROOT_PATH' , dirname(__FILE__));
if ( !defined('ROOT_PATH')) die('请定义根目录ROOT_PATH全局常量!');
// load autoload file
require ROOT_PATH . '/vendor/autoload.php';
/**
* run main function
* @param array $argv
* @param int $argc
*/
function main(array $argv , int $argc){
$commond = new \com_jjcbs\lib\CommondParse($argv);
$commondName = $commond->getCommondName();
switch ($commondName){
case 'build':
build($commond);
break;
case 'help':
showHelp();
break;
case 'clean':
clean($commond);
break;
default:
showHelp();
break;
}
}
/**
* out put help document
*/
function showHelp(){
echo "commond\nbuild\nhelp\nclean\n";
}
/**
* build annotation dir
* @param \com_jjcbs\lib\CommondParse $commondParse
*/
function build(\com_jjcbs\lib\CommondParse $commondParse){
try{
$fileName = $commondParse->getParamList()[0];
$config = \com_jjcbs\lib\ServiceFactory::getInstance(\com_jjcbs\service\AnnotationConfigServiceImpl::class);
if ( !file_exists($fileName)) throw new Exception($fileName . 'not exists');
$fileConfig = eval(str_replace('?>' , '' , str_replace('<?php' , '' , file_get_contents($fileName))));
$config->setConfig($fileConfig);
$fileDriver = new \com_jjcbs\lib\drivers\AnnotationFileCacheDriverImpl();
$fileDriver->scanNamespacesFiles();
die('build succeed');
}catch (Exception $e){
die('build error file' . $e->getMessage() . $e->getTraceAsString());
}
}
/**
* clean the build info
* @param \com_jjcbs\lib\CommondParse $commondParse
*/
function clean(\com_jjcbs\lib\CommondParse $commondParse){
}
main($argv , $argc);