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 testGetOption() { $args = array("cmd", "-d", "/var/tmp", "-f", "/tmp/test.txt"); $this->assertTrue(Sabel_Console::hasOption("d", $args)); $this->assertTrue(Sabel_Console::hasOption("f", $args)); $args = array("cmd", "-d", "/var/tmp", "-f", "/tmp/test.txt"); $this->assertEquals("/var/tmp", Sabel_Console::getOption("d", $args)); $this->assertEquals(array("cmd", "-f", "/tmp/test.txt"), $args); $args = array("cmd", "-d", "/var/tmp", "-f", "/tmp/test.txt"); $this->assertEquals("/tmp/test.txt", Sabel_Console::getOption("f", $args)); $this->assertEquals(array("cmd", "-d", "/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); } }
private function getOutputTables() { $args = $this->arguments; if (Sabel_Console::hasOption("t", $args)) { $tables = array(); $idx = array_search("-t", $args, true); for ($i = ++$idx, $c = count($args); $i < $c; $i++) { if ($args[$i][0] === "-") { break; } $tables[] = $args[$i]; } return $tables; } else { return array(); } }
protected function getFixtureMethod() { $method = "upFixture"; $arguments = $this->arguments; if (Sabel_Console::hasOption("up", $arguments)) { $index = array_search("--up", $arguments, true); unset($arguments[$index]); $arguments = array_values($arguments); } if (Sabel_Console::hasOption("down", $arguments)) { $index = array_search("--down", $arguments, true); unset($arguments[$index]); $arguments = array_values($arguments); $method = "downFixture"; } $this->arguments = $arguments; return $method; }
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; }