Example #1
0
    $id = 'help';
} else {
    // ad-hoc:(
    foreach ($r[0] as $opt) {
        if ($opt[0] == "v" || $opt[0] == "--version") {
            _Ethna_HandleGateway_ShowVersion();
            exit(2);
        }
    }
}
if (count($arg_list) == 0) {
    $id = 'help';
} else {
    $id = array_shift($arg_list);
}
$handler =& $eh->getHandler($id);
$handler->eh =& $eh;
if (Ethna::isError($handler)) {
    printf("no such command: %s\n\n", $id);
    $id = 'help';
    $handler =& $eh->getHandler($id);
    $handler->eh =& $eh;
    if (Ethna::isError($handler)) {
        exit(1);
        //  should not happen.
    }
}
// don't know what will happen:)
$handler->setArgList($arg_list);
$r = $handler->perform();
if (Ethna::isError($r)) {
Example #2
0
 function runCmd($id, $options = array())
 {
     if (($r = $this->create_ifnot_exists()) !== true) {
         return $r;
     }
     //   supplement basedir option.
     $in_basedir_opt = false;
     foreach ($options as $opt) {
         if ($opt == '-b' || $opt == '--basedir') {
             $in_basedir_opt = true;
         }
     }
     if (!$in_basedir_opt) {
         $base_opt = array('-b', $this->proj_basedir);
         $options = array_merge($base_opt, $options);
     }
     $eh = new Ethna_Handle();
     $handler = $eh->getHandler($id);
     if (Ethna::isError($handler)) {
         return $r;
     }
     ob_start();
     //  supress output.
     $handler->setArgList($options);
     $r = $handler->perform();
     ob_end_clean();
     if (Ethna::isError($r)) {
         return $r;
     }
     //  set plain ActionForm
     $ctl = $this->getController();
     $backend = $ctl->getBackend();
     $af = new Ethna_ActionForm($ctl);
     $backend->setActionForm($af);
     return true;
 }