protected function defineEnvironmentByOption($opt = "e", $default = DEVELOPMENT) { if (Sabel_Console::hasOption($opt, $this->arguments)) { $this->defineEnvironment(Sabel_Console::getOption($opt, $this->arguments)); } elseif (!defined("ENVIRONMENT")) { define("ENVIRONMENT", $default); } }
public function testGetOption2() { $args = array("cmd", "--dir=/var/tmp", "--file=/tmp/test.txt"); $this->assertEquals("/var/tmp", Sabel_Console::getOption("dir", $args)); $this->assertEquals(array("cmd", "--file=/tmp/test.txt"), $args); $args = array("cmd", "--dir=/var/tmp", "--file=/tmp/test.txt"); $this->assertEquals("/tmp/test.txt", Sabel_Console::getOption("file", $args)); $this->assertEquals(array("cmd", "--dir=/var/tmp"), $args); }
public function run() { $args = $this->arguments; if (Sabel_Console::hasOption("v", $args)) { $this->version = Sabel_Console::getOption("v", $args); } if (Sabel_Console::hasOption("a", $args)) { $this->installAddon(Sabel_Console::getOption("a", $args)); } elseif (Sabel_Console::hasOption("l", $args)) { // library } elseif (Sabel_Console::hasOption("p", $args)) { // processor } else { } }
public function run() { $args = $this->arguments; if (Sabel_Console::hasOption("v", $args)) { $version = Sabel_Console::getOption("v", $args); } else { $version = "HEAD"; } if (Sabel_Console::hasOption("a", $args)) { $this->installAddon(Sabel_Console::getOption("a", $args), $version); } else { $message = __METHOD__ . "() invalid install option."; throw new Sabel_Exception_Runtime($message); } }
public function run() { if (count($this->arguments) < 2) { $this->usage(); exit; } $method = $this->getFixtureMethod(); $this->defineEnvironment($this->arguments[0]); Sabel_Db_Config::initialize(new Config_Database()); if (Sabel_Console::hasOption("export", $this->arguments)) { unset($this->arguments[array_search("--export", $this->arguments, true)]); return $this->export("fixture"); } elseif (Sabel_Console::hasOption("export-csv", $this->arguments)) { $dir = Sabel_Console::getOption("export-csv", $this->arguments); if ($dir === null) { $dir = RUN_BASE . DS . "data"; } return $this->export("csv", $dir); } $fixtureName = $this->arguments[1]; if ($fixtureName === "all") { foreach (scandir(FIXTURE_DIR) as $item) { if ($item === "." || $item === "..") { continue; } Sabel::fileUsing(FIXTURE_DIR . DS . $item, true); $className = "Fixture_" . substr($item, 0, strlen($item) - 4); $instance = new $className(); $instance->initialize(); $instance->{$method}(); } } else { $filePath = FIXTURE_DIR . DS . $fixtureName . ".php"; if (Sabel::fileUsing($filePath, true)) { $className = "Fixture_" . $fixtureName; $instance = new $className(); $instance->initialize(); $instance->{$method}(); $this->success(ucfirst($method) . " " . $fixtureName); } else { $this->error("no such fixture file. '{$filePath}'"); } } }
protected function readOptions($args) { if (in_array("--overwrite", $args, true)) { $index = array_search("--overwrite", $args) + 1; for ($i = $index, $c = count($args); $i < $c; $i++) { if (substr($args[$i], 0, 2) === "--") { break; } $path = $this->targetDir . DS . $args[$i]; if (is_file($path)) { unlink($path); } elseif (is_dir($path)) { $fs = new Sabel_Util_FileSystem($path); $fs->rmdir(); } } } if (in_array("--ignore", $args, true)) { $index = array_search("--ignore", $args) + 1; for ($i = $index, $c = count($args); $i < $c; $i++) { if (substr($args[$i], 0, 2) === "--") { break; } $this->ignore[$args[$i]] = 1; } } if (Sabel_Console::hasOption("l", $args)) { if (($lang = Sabel_Console::getOption("l", $args)) !== null) { $lang = strtolower($lang); if (is_dir($this->skeletonDir . DS . $lang)) { $this->lang = $lang; } } } }
protected function defineMigrationDirectory() { if (Sabel_Console::hasOption("d", $this->arguments)) { $dir = Sabel_Console::getOption("d", $this->arguments); } else { $dir = RUN_BASE . DS . "migration" . DS . $this->getConnectionName(); } if (!is_dir($dir)) { $this->error("no such directory '{$dir}'."); exit; } Sabel_Db_Migration_Manager::setDirectory($dir); return $dir; }
private function createOptions() { $args = $this->arguments; if (Sabel_Console::hasOption("f", $args)) { $this->fileName = Sabel_Console::getOption("f", $args); } /* if (Sabel_Console::hasOption("dl", $args)) { $this->defaultLocale = Sabel_Console::getOption("dl", $args); } */ if (Sabel_Console::hasOption("l", $args)) { $idx = array_search("-l", $args, true); for ($i = ++$idx, $c = count($args); $i < $c; $i++) { if ($args[$i][0] === "-") { break; } $this->locales[] = $args[$i]; } } $this->arguments = $args; }