public function index()
 {
     if (!Director::is_cli()) {
         return "The SilverStripe Interactive Command-line doesn't work in a web browser." . " Use 'sake interactive' from the command-line to run.";
     }
     /* Try using PHP_Shell if it exists */
     @(include 'php-shell-cmd.php');
     /* Fall back to our simpler interface */
     if (empty($__shell)) {
         set_error_handler(array($this, 'error_handler'));
         echo "SilverStripe Interactive Command-line (REPL interface). Type help for hints.\n\n";
         while (true) {
             echo CLI::text("?> ", "cyan");
             echo CLI::start_colour("yellow");
             $command = trim(fgets(STDIN, 4096));
             echo CLI::end_colour();
             if ($command == 'help' || $command == '?') {
                 print "help or ? to exit\n";
                 print "quit or \\q to exit\n";
                 print "install PHP_Shell for a more advanced interface with" . " auto-completion and readline support\n\n";
                 continue;
             }
             if ($command == 'quit' || $command == '\\q') {
                 break;
             }
             // Simple command processing
             if (substr($command, -1) == ';') {
                 $command = substr($command, 0, -1);
             }
             $is_print = preg_match('/^\\s*print/i', $command);
             $is_return = preg_match('/^\\s*return/i', $command);
             if (!$is_print && !$is_return) {
                 $command = "return ({$command})";
             }
             $command .= ";";
             try {
                 $result = eval($command);
                 if (!$is_print) {
                     print_r($result);
                 }
                 echo "\n";
             } catch (Exception $__repl_exception) {
                 echo CLI::start_colour("red");
                 printf('%s (code: %d) got thrown' . PHP_EOL, get_class($__repl_exception), $__repl_exception->getCode());
                 print $__repl_exception;
                 echo "\n";
             }
         }
     }
 }
 protected function writeTest($test)
 {
     if ($test['status'] != TEST_SUCCESS) {
         $filteredTrace = array();
         foreach ($test['trace'] as $item) {
             if (isset($item['file']) && strpos($item['file'], 'PHPUnit/Framework') === false && !isset($item['class'])) {
                 $filteredTrace[] = $item;
             }
             if (isset($item['class']) && isset($item['function']) && $item['class'] == 'PHPUnit_Framework_TestSuite' && $item['function'] == 'run') {
                 break;
             }
         }
         $color = $test['status'] == 2 ? 'yellow' : 'red';
         echo "\n" . CLI::text($test['name'] . "\n" . $test['message'] . "\n", $color, null);
         echo Backtrace::get_rendered_backtrace($filteredTrace, true);
         echo "--------------------\n";
     }
 }
 public function renderVariable($val, $caller)
 {
     $output = PHP_EOL;
     $output .= CLI::text(str_repeat('=', self::config()->columns), 'green');
     $output .= PHP_EOL;
     $output .= CLI::text($this->formatCaller($caller), 'blue', null, true);
     $output .= PHP_EOL . PHP_EOL;
     if (is_string($val)) {
         $output .= wordwrap($val, self::config()->columns);
     } else {
         $output .= var_export($val, true);
     }
     $output .= PHP_EOL;
     $output .= CLI::text(str_repeat('=', self::config()->columns), 'green');
     $output .= PHP_EOL;
     return $output;
 }