public static function run($class) { $args = $_SERVER["argv"]; array_shift($args); $class = array_shift($args); unshift_include_path(RUN_BASE . DS . "tasks"); if (class_exists($class, true)) { $ins = new $class(); $ins->setArguments($args); if (isset($args[0]) && ($args[0] === "-h" || $args[0] === "--help")) { $ins->usage(); } else { try { if ($ins->hasMethod("initialize")) { $ins->initialize(); } $ins->run(); if ($ins->hasMethod("finalize")) { $ins->finalize(); } } catch (Exception $e) { Sabel_Console::error($e->getMessage()); } } } else { Sabel_Console::error("such a task doesn't exist."); } }
public function downgrade($query) { if (is_string($query)) { $this->downgradeQueries[] = $query; } else { Sabel_Console::error("argument must be a string."); exit; } }
private function setBoolean($bool, $key) { if (is_bool($bool)) { $this->column->{$key} = $bool; } else { Sabel_Console::error("argument for {$key}() should be a boolean."); exit; } }
public function unique($columnNames) { if (is_string($columnNames)) { $this->uniques[] = (array) $columnNames; } elseif (is_array($columnNames)) { $this->uniques[] = $columnNames; } else { Sabel_Console::error("unique() argument should be a string or an array."); exit; } }
public function start($testName, $testFilePath) { if (is_readable($testFilePath)) { try { $testCaseName = $this->classPrefix . $testName; $this->doRun($this->getTest($testCaseName, $testFilePath)); } catch (Exception $e) { Sabel_Console::error("couldn't run the TestSuite: " . $e->getMessage()); } } else { Sabel_Console::error($testFilePath . " not found"); } }
public function testMessage() { $_SERVER["IS_WINDOWS"] = true; ob_start(); Sabel_Console::success("success"); $result = ob_get_clean(); $this->assertEquals("[SUCCESS] success", rtrim($result)); ob_start(); Sabel_Console::warning("warning"); $result = ob_get_clean(); $this->assertEquals("[WARNING] warning", rtrim($result)); ob_start(); Sabel_Console::error("failure"); $result = ob_get_clean(); $this->assertEquals("[FAILURE] failure", rtrim($result)); ob_start(); Sabel_Console::message("message"); $result = ob_get_clean(); $this->assertEquals("[MESSAGE] message", rtrim($result)); }
public static function getFiles() { if (!is_dir(self::$directory)) { Sabel_Console::error("no such dirctory. '" . self::$directory . "'"); exit; } $files = array(); foreach (scandir(self::$directory) as $file) { $num = substr($file, 0, strpos($file, "_")); if (!is_numeric($num)) { continue; } if (isset($files[$num])) { Sabel_Console::error("the same version({$num}) files exists."); exit; } else { $files[$num] = $file; } } ksort($files); return $files; }
public function error($msg) { echo Sabel_Console::error($msg); }