public function run()
 {
     if (version_compare(phpversion(), '5.4.0', '<')) {
         Console::writeWarning("you must have PHP 5.4.0 or greater to use this feature. you are using PHP " . phpversion() . "...");
     } else {
         // set-up defaults
         $publicDir = Config::getOption("publicDir");
         $coreDir = Config::getOption("coreDir");
         $host = Console::findCommandOptionValue("host");
         $host = $host ? $host : "localhost";
         $port = Console::findCommandOptionValue("port");
         $host = $port ? $host . ":" . $port : $host . ":8080";
         $quiet = Console::findCommandOption("quiet");
         // set-up the base command
         $command = $this->pathPHP . " -S " . $host . " " . $coreDir . "/server/router.php";
         $commands = array();
         $commands[] = array("command" => $command, "cwd" => $publicDir, "timeout" => null, "idle" => 1800);
         // get the watch command info
         if (Console::findCommandOption("with-watch")) {
             $watchCommand = new WatchCommand();
             $commands[] = array("command" => $watchCommand->build() . " --no-procs", "timeout" => null, "idle" => 1800);
         }
         Console::writeInfo("server started on http://" . $host . " - use ctrl+c to exit...");
         $processSpawner = new ProcessSpawner();
         $processSpawner->spawn($commands, $quiet);
     }
 }
 public function run()
 {
     if (Console::findCommandOption("list")) {
         // get all of the options
         $options = Config::getOptions();
         // sort 'em alphabetically
         ksort($options);
         // find length of longest option
         $lengthLong = 0;
         foreach ($options as $optionName => $optionValue) {
             $lengthLong = strlen($optionName) > $lengthLong ? strlen($optionName) : $lengthLong;
         }
         // iterate over each option and spit it out
         foreach ($options as $optionName => $optionValue) {
             $optionValue = is_array($optionValue) ? implode(", ", $optionValue) : $optionValue;
             $optionValue = !$optionValue ? "false" : $optionValue;
             $spacer = Console::getSpacer($lengthLong, strlen($optionName));
             Console::writeLine("<info>" . $optionName . ":</info>" . $spacer . $optionValue);
         }
     } else {
         if (Console::findCommandOption("get")) {
             // figure out which optino was passed
             $searchOption = Console::findCommandOptionValue("get");
             $optionValue = Config::getOption($searchOption);
             // write it out
             if (!$optionValue) {
                 Console::writeError("the --get value you provided, <info>" . $searchOption . "</info>, does not exists in the config...");
             } else {
                 $optionValue = is_array($optionValue) ? implode(", ", $optionValue) : $optionValue;
                 $optionValue = !$optionValue ? "false" : $optionValue;
                 Console::writeInfo($searchOption . ": <ok>" . $optionValue . "</ok>");
             }
         } else {
             if (Console::findCommandOption("set")) {
                 // find the value that was passed
                 $updateOption = Console::findCommandOptionValue("set");
                 $updateOptionBits = explode("=", $updateOption);
                 if (count($updateOptionBits) == 1) {
                     Console::writeError("the --set value should look like <info>optionName=\"optionValue\"</info>. nothing was updated...");
                 }
                 // set the name and value that were passed
                 $updateName = $updateOptionBits[0];
                 $updateValue = $updateOptionBits[1][0] == "\"" || $updateOptionBits[1][0] == "'" ? substr($updateOptionBits[1], 1, strlen($updateOptionBits[1]) - 1) : $updateOptionBits[1];
                 // make sure the option being updated already exists
                 $currentValue = Config::getOption($updateName);
                 if (!$currentValue) {
                     Console::writeError("the --set option you provided, <info>" . $updateName . "</info>, does not exists in the config. nothing will be updated...");
                 } else {
                     Config::updateConfigOption($updateName, $updateValue);
                 }
             } else {
                 // no acceptable options were passed so write out the help
                 Console::writeHelpCommand($this->command);
             }
         }
     }
 }
 public function run()
 {
     // set-up required vars
     $options = array();
     $options["moveStatic"] = Console::findCommandOption("p|patternsonly") ? false : true;
     $options["noCacheBuster"] = Console::findCommandOption("n|nocache");
     $g = new Generator();
     $g->generate($options);
     $g->printSaying();
 }
Пример #4
0
 public function build()
 {
     $command = $this->pathPHP . " " . $this->pathConsole . " --" . $this->command;
     if (Console::findCommandOption("p|patternsonly")) {
         $command .= " --patternsonly";
     }
     if (Console::findCommandOption("n|nocache")) {
         $command .= " --nocache";
     }
     return $command;
 }
 public function run()
 {
     // set-up required vars
     $options = array();
     $options["exportFiles"] = true;
     $options["exportClean"] = Console::findCommandOption("clean");
     $options["moveStatic"] = false;
     FileUtil::cleanExport();
     $g = new Generator();
     $g->generate($options);
     FileUtil::exportStatic();
 }
 public function run()
 {
     if (Console::findCommandOption("list")) {
         $this->listOptions();
     } else {
         if (Console::findCommandOption("get")) {
             $this->getOption();
         } else {
             if (Console::findCommandOption("set")) {
                 $this->setOption();
             } else {
                 Console::writeHelpCommand($this->command);
             }
         }
     }
 }
 public function run()
 {
     // find the value given to the command
     $init = Console::findCommandOption("i|init");
     $starterkit = Console::findCommandOptionValue("f|install");
     $suggestions = Console::findCommandOption("suggestions");
     if ($suggestions) {
         $this->starterKitSuggestions();
     } else {
         if ($init || $starterkit) {
             $this->starterKitInstall($starterkit, $init);
         } else {
             Console::writeHelpCommand($this->command);
         }
     }
 }
 public function run()
 {
     // find the value given to the command
     $init = Console::findCommandOption("i|init");
     $starterkit = Console::findCommandOptionValue("f|install");
     if ($init) {
         $patternEngine = Config::getOption("patternExtension");
         $starterkit = "pattern-lab/starterkit-" . $patternEngine . "-base";
     }
     if ($starterkit) {
         // download the starterkit
         $f = new Fetch();
         $f->fetchStarterKit($starterkit);
     } else {
         Console::writeHelpCommand($this->command);
     }
 }
Пример #9
0
 public function run()
 {
     // set-up required vars
     $options = array();
     $options["moveStatic"] = Console::findCommandOption("p|patternsonly") ? false : true;
     $options["noCacheBuster"] = Console::findCommandOption("n|nocache");
     // DEPRECATED
     // $options["autoReload"]    = Console::findCommandOption("r|autoreload");
     // see if the starterKit flag was passed so you know what dir to watch
     if (Console::findCommandOption("sk")) {
         // load the starterkit watcher
         $w = new Watcher();
         $w->watchStarterKit();
     } else {
         // load the generator
         $g = new Generator();
         $g->generate($options);
         // load the watcher
         $w = new Watcher();
         $w->watch($options);
     }
 }