9 require_once __DIR__ .
'/Class.Dcp_Utils_WStart.php';
17 public static function usage($me)
24 $me [<options>] [--all|<operations>]
28 -v|--verbose Increase verbosity (can be specified multiple times to increase verbosity).
32 -r|--resetAutoloader Re-generate
class autoloader.
33 -l|--links Re-generate Images and Docs symlinks.
34 -c|--clearFile Clear cached content.
35 -u|--upgradeVersion Increment WVERSION.
36 -b|--dbconnect Configure CORE_DBCONNECT method
37 -s|--style Recompute style assets.
38 -m|--unStop Remove maintenance mode.
51 private static function bootstrap()
53 $contextRoot = realpath(__DIR__ . DIRECTORY_SEPARATOR .
'..');
54 if ($contextRoot ===
false) {
55 throw new WStartCLIException(sprintf(
"Could not get context root directory from directory '%s'!", __DIR__));
57 if (chdir($contextRoot) ===
false) {
58 throw new WStartCLIException(sprintf(
"Could not change current working directory to '%s'!", $contextRoot));
60 set_include_path($contextRoot . PATH_SEPARATOR . sprintf(
'%s/WHAT', $contextRoot) . PATH_SEPARATOR . get_include_path());
61 require_once sprintf(
'%s/WHAT/Lib.Prefix.php', $contextRoot);
62 require_once sprintf(
'%s/WHAT/Class.Dcp_Utils_WStart.php', $contextRoot);
71 public static function run(&$argv)
73 $me = array_shift($argv);
77 $contextRoot = self::bootstrap();
84 while (count($argv) > 0) {
85 $opt = array_shift($argv);
97 if (!isset($opts[
'verbose'])) {
109 case '--resetAutoloader':
110 $opts[
'resetAutoloader'] =
true;
115 $opts[
'links'] =
true;
120 $opts[
'clearFile'] =
true;
124 case '--upgradeVersion':
125 $opts[
'upgradeVersion'] =
true;
130 $opts[
'dbconnect'] =
true;
135 $opts[
'style'] =
true;
140 $opts[
'unStop'] =
true;
144 printf(
"ERROR: Unknown argument/option '%s'!\n", $opt);
150 if (isset($opts[
'help'])) {
158 'reapplyDatabaseParameters' =>
true,
159 'clearAutoloadCache' =>
false,
160 'imageAndDocsLinks' =>
false,
161 'clearFileCache' =>
false,
162 'refreshJsVersion' =>
false,
163 'configureDbConnect' =>
false,
168 if (isset($opts[
'resetAutoloader'])) {
169 $operations[
'clearAutoloadCache'] =
true;
172 if (isset($opts[
'links'])) {
173 $operations[
'imageAndDocsLinks'] =
true;
176 if (isset($opts[
'clearFile'])) {
177 $operations[
'clearFileCache'] =
true;
180 if (isset($opts[
'upgradeVersion'])) {
181 $operations[
'refreshJsVersion'] =
true;
184 if (isset($opts[
'dbconnect'])) {
185 $operations[
'configureDbConnect'] =
true;
188 if (isset($opts[
'style'])) {
189 $operations[
'style'] =
true;
192 if (isset($opts[
'unStop'])) {
193 $operations[
'unStop'] =
true;
200 foreach ($operations as $name => & $needExec) {
205 $wstart =
new WStart($contextRoot);
207 if (isset($opts[
'verbose'])) {
208 $wstart->setVerbose($opts[
'verbose']);
210 foreach ($operations as $name => $needExec) {
214 if (!method_exists($wstart, $name)) {
217 if (call_user_func_array(array(
220 ) , array()) ===
false) {
221 throw new WStartCLIException(sprintf(
"Execution of '%s' returned with error!", $name));
240 if (mb_substr($msg, -1) !=
"\n") {
Exception class use exceptionCode to identifiy correctly exception.