예제 #1
0
 public function renderDefault()
 {
     CliLogger::log("\nSomething bad!\n", CliLogger::ERROR);
     if ($this->params["exception"]->getCode() == 404) {
         BasePresenter::Help();
     }
 }
예제 #2
0
 public function helpOptions($module)
 {
     Options::help($module, 1);
     CliLogger::log("\n", Debugger::ERROR);
 }
예제 #3
0
파일: Options.php 프로젝트: jiang51/monda
 private static function parseOne($params, $key, $short, $long, $desc, $default = null, $defaulthelp = false, $choices = false, $from = false)
 {
     self::$copts[$key] = array("short" => $short, "long" => $long, "description" => $desc, "default" => $default, "defaulthelp" => $defaulthelp, "choices" => $choices);
     $fromdefault = false;
     if ($short && array_key_exists($short, $params)) {
         $value = stripslashes($params[$short]);
     } elseif (array_key_exists($long, $params)) {
         $value = stripslashes($params[$long]);
     } elseif (array_key_exists("_{$short}", $params)) {
         $value = !$params["_{$short}"];
     } elseif (array_key_exists("_{$long}", $params)) {
         $value = !$params["_{$long}"];
     } else {
         $value = $default;
         $fromdefault = true;
     }
     if ($choices) {
         if (array_search($value, $choices) === false) {
             BasePresenter::mexit(14, sprintf("Bad option %s for parameter %s(%s). Possible values: {%s}\n", $value, $short, $long, join($choices, "|")));
         }
     }
     $objkey = $key;
     if (isset(self::$opts->{$objkey})) {
         if (!$fromdefault) {
             self::$paramsrc[$key] = $from;
             self::$opts->{$objkey} = $value;
             if (!self::isDefault($key) && $value != self::$opts->{$objkey}) {
                 CliLogger::log("Overwriting option {$key} from {$from}.\n", Debugger::WARNING);
             }
             self::$defaults[$key] = false;
         }
     } else {
         self::$opts->{$objkey} = $value;
         self::$paramsrc[$key] = $from;
         self::$defaults[$key] = $fromdefault;
         if ($long = "debug") {
             CliLogger::__init();
         }
         if ($fromdefault) {
             CliLogger::log("Default option {$key}({$desc}) to " . strtr(Debugger::dump(self::$opts->{$objkey}, true), "\n", " ") . "\n", Debugger::INFO);
         } else {
             CliLogger::log("Setting option {$key}({$desc}) (from {$from}) to " . strtr(Debugger::dump(self::$opts->{$objkey}, true), "\n", " ") . "\n", Debugger::WARNING);
         }
     }
 }