private function install($args) { $flats = array(); $flags = array(); foreach($args as $arg) { preg_match('/^(\-?[a-zA-Z])([^\s]+)$/', $arg, $matches); if (count($matches) != 3) continue; $matches[0][0] == '-' ? $flags[$matches[1][1]] = $matches[2] : $flats[] = $matches[0]; } if (count($flats) != 1) return $this->failtown('format: `spark install -v1.0.0 name`'); $spark_name = $flats[0]; $version = array_key_exists('v', $flags) ? $flags['v'] : 'HEAD'; // retrieve the spark details foreach ($this->spark_sources as $source) { SparkUtils::notice("Retrieving spark detail from " . $source->get_url()); $spark = $source->get_spark_detail($spark_name, $version); if ($spark != null) break; } // did we find the details? if ($spark == null) throw new SparkException("Unable to find spark: $spark_name ($version) in any sources"); // verify the spark, and put out warnings if needed $spark->verify(); // retrieve the spark SparkUtils::notice("From Downtown! Retrieving spark from " . $spark->location_detail()); if (!$spark->retrieve()) throw new SparkException('Failed to retrieve the spark ;('); SparkUtils::notice('Installing spark'); $spark->install(); SparkUtils::notice('Spark installed to ' . $spark->installed_path() . ' - You\'re on fire!'); }