-
Notifications
You must be signed in to change notification settings - Fork 28
/
apply.php
executable file
·63 lines (51 loc) · 1.45 KB
/
apply.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
#!/usr/bin/php
<?php
if (version_compare(PHP_VERSION, '5.3.0') <= 0) {
throw new Exception('EnvSettingsTool needs at least PHP 5.3');
}
define('EST_ROOTDIR', dirname(__FILE__));
/**
* Simple autoloading
*
* @param string $className
* @return bool
* @throws Exception
* @author Fabrizio Branca
* @since 2012-09-19
*/
spl_autoload_register(function ($className) {
// don't do autoloading for external classes
if (strpos($className, 'Est_') !== 0) {
return false;
}
$fileName = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
if (!file_exists($fileName)) {
throw new Exception("File '$fileName' not found.");
}
require_once($fileName);
if (!class_exists($className) && !interface_exists($className)) {
throw new Exception("File '$fileName' does not contain class/interface '$className'");
}
return true;
});
try {
if (empty($_SERVER['argv'][1])) {
throw new Exception('Please specify the environment');
}
if (getenv('NO_COLOR')) {
Est_CliOutput::$active = false;
}
$env = $_SERVER['argv'][1];
$settingsFile = empty($_SERVER['argv'][2]) ? '../settings/settings.csv' : $_SERVER['argv'][2];
$processor = new Est_Processor($env, $settingsFile);
$res = $processor->apply();
$processor->printResults();
if (!$res) {
echo "\nERROR: Stopping execution because an error has occured!\n\n";
exit(1);
}
} catch (Exception $e) {
echo "\nERROR: {$e->getMessage()}\n\n";
exit(1);
}