/**
  * requires the classes to be tested
  */
 public function setUp()
 {
     require_once 'Jm/Autoloader.php';
     $this->console = Jm_Console::singleton();
     $this->console->stdin()->enforceIsatty(TRUE);
     $this->console->stdout()->enforceIsatty(TRUE);
     $this->console->stderr()->enforceIsatty(TRUE);
 }
/**
 *
 */
function progressbar($now, $total, $w = 35)
{
    $console = Jm_Console::singleton();
    $console->write('[', 'white,light');
    $n = floor($now * $w / $total);
    $console->write(str_repeat('+', $n), 'green,light');
    if ($n < $w) {
        $console->write(']', 'green,light');
        $console->write(str_repeat('-', $w - $n - 1), 'red,light');
    }
    $console->write(']', 'white,light');
}
Beispiel #3
0
<?php

require_once 'Jm/Autoloader.php';
Jm_Autoloader::singleton()->prependPath('lib/php');
$console = Jm_Console::singleton();
$console->write('hello', 'black,bg:yellow');
$console->write(' ');
$console->writeln('world', 'black,bg:red');
Beispiel #4
0
 /**
  * Returns a reference to the console. The returned object is a singleton.
  *
  * @return Jm_Console
  */
 public static function singleton()
 {
     if (!self::$singletonInstance) {
         $class = get_called_class();
         self::$singletonInstance = new $class();
     }
     return self::$singletonInstance;
 }