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() { if ($helpCommand = Console::findCommandValue("h|help")) { $helpCommand = str_replace("-", "", $helpCommand); if ($commandFound = Console::findCommandLong($helpCommand)) { Console::writeHelpCommand($commandFound); } else { Console::writeHelp(); } } else { Console::writeHelp(); } }
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); } }
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); } }