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 build()
 {
     $command = $this->pathPHP . " " . $this->pathConsole . " --" . $this->command;
     $host = Console::findCommandOptionValue("host");
     $port = Console::findCommandOptionValue("port");
     if ($host) {
         $command .= " --host " . $host;
     }
     if ($port) {
         $command .= " --port " . $port;
     }
     return $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()
 {
     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";
         // start-up the server with the router
         Console::writeInfo("server started on " . $host . ". use ctrl+c to exit...");
         passthru("cd " . $publicDir . " && " . $_SERVER["_"] . " -S " . $host . " " . $coreDir . "/server/router.php");
     }
 }
 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);
     }
 }
 /**
  * Set the given option to the given value
  */
 protected function setOption()
 {
     // 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);
         Console::writeInfo("config option updated...");
     }
 }
 public function run()
 {
     // find the value given to the command
     $package = Console::findCommandOptionValue("p|package");
     if ($package) {
         // if <prompt> was passed ask the user for the package name
         if ($package == "prompt") {
             $prompt = "what is the name of the package you want to fetch?";
             $options = "(ex. pattern-lab/plugin-kss)";
             $package = Console::promptInput($prompt, $options);
         }
         // make sure it looks like a valid package
         if (strpos($package, "/") === false) {
             Console::writeError("that wasn't a valid package name. it should look like <info>pattern-lab/plugin-kss</info>...");
         }
         // run composer via fetch
         $f = new Fetch();
         $f->fetchPackage($package);
     } else {
         Console::writeHelpCommand($this->command);
     }
 }