Example #1
0
 public function main($args)
 {
     echo "Eregansu Command-line Shell\n";
     if (function_exists('readline')) {
         echo "- Readline is available\n";
         $this->useReadline = true;
     }
     if (defined('CLUSTER_IRI')) {
         require_once APPS_ROOT . 'cluster/model.php';
         $this->cluster = ClusterModel::getInstance();
     }
     $this->stdin = fopen('php://stdin', 'r');
     $router = new ShellRouter();
     while (!$this->exit) {
         $cmdline = $this->getline();
         $cmd = $this->parseline($cmdline);
         if (!count($cmd) || !strlen($cmd[0])) {
             continue;
         }
         if (!strcmp($cmd[0], 'exit')) {
             break;
         }
         Error::$throw = true;
         $req = Request::requestForSAPI('cli');
         $req->params = $cmd;
         try {
             try {
                 $router->process($req);
             } catch (TerminalErrorException $ex) {
             }
         } catch (Exception $e) {
             echo $e . "\n";
         }
         $req = null;
     }
 }