Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 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 {
     }
 }
Esempio n. 4
0
 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);
     }
 }
Esempio n. 5
0
 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();
     }
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
 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;
             }
         }
     }
 }
Esempio n. 8
0
 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;
 }
Esempio n. 9
0
 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;
 }