-
Notifications
You must be signed in to change notification settings - Fork 0
/
zombie.php
executable file
·80 lines (68 loc) · 2.46 KB
/
zombie.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
# Copyright (c) 2011, Regaltic LLC. This file is
# licensed under the General Public License version 3.
# See the LICENSE file.
require_once(__DIR__ . "/util/util.php");
require_once(__DIR__ . "/util/autoload.php");
require_once(__DIR__ . "/../config/config.php");
function cliMain($argv) {
$argc = count($argv);
if ($argc < 2) {
die("Usage: zombie.php <action> <option=value> ...\n" .
"Availabe actions:\n" .
"\tcompile\n" .
"\tcreate-app\n");
}
$action = $argv[1];
$options = array();
for ($i = 2; $i < $argc; ++$i) {
$opt = explode("=", $argv[$i], 2);
if (count($opt) == 2) {
$options[$opt[0]] = $opt[1];
} else {
$options[$opt[0]] = true;
}
}
if ($action == "generate-app") {
if (!isset($options['app'])) {
die ("Usage: zombie.php generate-app app=<app name> [template=<template_name>] [option=<value>] ...\n");
}
$template = (isset($options['template']) ? $options['template'] : 'basic');
$base_dir = "/config/generator";
$template_file = realpath(__DIR__ . "/../config/generator/" . $template) . "/template.php";
if (!file_exists($template_file)) {
$base_dir = "/zombie-core/generator/";
$template_file = __DIR__ . "/generator/" . $template . "/template.php";
if (!file_exists($template_file)) {
die("unknown template: " . $template . "\n");
}
}
$app = $options['app'];
require_once(__DIR__ . "/generator/ZombieTemplate.php");
require($template_file);
$template_class = underscoreToClass($template . "_template");
$template = new $template_class($template, $app, $base_dir, $options);
$template->run();
} else if ($action == "compile") {
require(__DIR__ . "/util/compile/compile.php");
compile($options);
} else if ($action == "migrate") {
require(__DIR__ . "/util/migrate/migrate.php");
migrate($options);
} else if ($action == "deploy") {
require(__DIR__ . "/util/deploy.php");
deploy();
} else if ($action == "install-package") {
if (!isset($options['name'])) {
die ("Usage: zombie.php install-package name=<package name>\n");
}
require(__DIR__ . "/packages/installer.php");
installPackage($options['name']);
} else if ($action == "kachow") {
echo "kachow!\n";
} else {
echo "Error: unknown action '" . $action . "'.\n";
}
}
cliMain($argv);
?>