/**
  * Checks if the given virtual command line interface exists by id.
  *
  * @param $id The id used to create the original virtual command line interface.
  *
  * @return bool Returns true if the given $id exists otherwise false.
  */
 static function has_cli($id)
 {
     $cli_list = VCLIManager::cli_list();
     $list = [];
     foreach ($cli_list as $c) {
         $c = new GString($c);
         array_push($list, $c->delRightMost(chr(9))->__toString());
     }
     return in_array($id, $list);
 }
 /**
  * Get the current results from the virtual commandline interface. Non-blocking. Specify an optional command_id to
  * retrieve a command's specific results or none (-1 default) to return all results of the current given session.
  *
  * @param int $command_id Optional id of a specific command to get the results for or -1 (default) to return all
  *
  * @return string The given results.
  */
 public function get_results($command_id = -1)
 {
     $args = array('wait_for' => $command_id, 'console_id' => $this->id, 'action' => 'result');
     $results = VCLIManager::send($args);
     // Filter out password and ~~~done~~~ echos if present
     $lines = explode(Chr(10), $results);
     $results = "";
     $prev = "";
     foreach ($lines as $line) {
         // Hide passwords in response to prompts
         if (substr(strtolower($prev), 0, 8) === "password") {
             $line = "********" . $this->eol;
         }
         // Hide done waiting mechanism
         if (false !== strpos($line, "~~~done~~~")) {
             $line = str_replace($this->concat_char . "echo ~~~done~~~", "", $line);
             $line = str_replace("~~~done~~~", "", $line);
         }
         // Eat echo'd command on Windows
         if (VCLIManager::$platform === 'win32') {
             if ($line === substr($prev, -strlen($line)) && strlen($prev) > strlen($line)) {
                 continue;
             }
         }
         // Eat invisible [?1034h
         if (substr($line, 0, 8) === '[?1034h') {
             $line = substr($line, 8);
         }
         $prev = $line;
         $results .= $line . Chr(10);
     }
     // Parse out the percent complete from the initial response
     $results = new GString($results);
     $this->completed = intval($results->getLeftMost("|\n"));
     return $results->delLeftMost("|\n")->__toString();
 }
 /**
  * Uncomment the line containing the key that was found from a prior find
  * method call.
  */
 function uncomment()
 {
     if (false === $this->last_index) {
         return;
     }
     if ($this->is_commented()) {
         $line = new GString($this->block[$this->last_index]);
         $comment = $this->comment_chars;
         if (false === strpos($this->block[$this->last_index], $comment)) {
             $comment = new GString($comment);
             // accomodate missing whitespace
             $comment = $comment->trim()->__toString();
         }
         $this->block[$this->last_index] = $line->delLeftMost($comment)->__toString();
     }
 }