Inheritance: implements consolekit\TextWriter
Example #1
0
 /**
  * init bim applications
  * @throws \Exception
  */
 public static function init()
 {
     $conf = new Config(__DIR__ . "/config/commands.json");
     $console = new Console($conf->get("commands"));
     # run commands
     $console->run();
 }
Example #2
0
 public static function test()
 {
     $out = new Console();
     $singleton1 = Singleton::getInstance('Singleton 1');
     $singleton2 = Singleton::getInstance('Singleton 2');
     $out->writeln($singleton1->getName());
     $out->writeln($singleton2->getName());
 }
 public static function test()
 {
     /**
      * @var \Patterns\AbstractFactoryPattern\AbstractComputerFactory $factory
      */
     $computerFactories = [new ExpensiveComputerFactory(), new CheapComputerFactory()];
     foreach ($computerFactories as $factory) {
         $out = new Console();
         $out->writeln($factory->getHdd()->saveData());
         $out->writeln($factory->getProcessor()->processData());
     }
 }
Example #4
0
        $this->writeln(sprintf('hello %s!', $name));
    }
    /**
     * Says hi to someone
     *
     * @arg name The name of the person to say hello to
     */
    public function executeHi(array $args, array $options = array())
    {
        $this->writeln(sprintf('hi %s!', $args[0]));
    }
}
/**
 * Displays a progress bar
 *
 * @opt total Number of iterations
 * @opt usleep Waiting time in microsecond between each iteration
 */
function progress($args, $options, $console)
{
    $total = isset($options['total']) ? $options['total'] : 100;
    $usleep = isset($options['usleep']) ? $options['usleep'] : 10000;
    $progress = new ProgressBar($console, $total);
    for ($i = 0; $i < $total; $i++) {
        $progress->incr();
        usleep($usleep);
    }
    $progress->stop();
}
$console = new Console(array('hello' => 'HelloWorldCommand', 'SayHelloCommand', 'SayCommand', 'progress'));
$console->run();
Example #5
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->addCommandsFromDir(__DIR__ . '/Console', 'Jasny\\DBVC\\Console');
     $this->setDefaultCommand('help');
 }
Example #6
0
 /**
  * Writes a line of text
  * 
  * @param string $text
  * @param int|array $formatOptions
  * @param int $pipe
  * @return Command
  */
 public function writeln($text, $formatOptions = array(), $pipe = TextWriter::STDOUT)
 {
     $this->console->writeln($this->format($text, $formatOptions), $pipe);
     return $this;
 }
Example #7
0
 /**
  * Registers a callback to call when a command is
  * executed
  *
  * @param string $command
  * @param callback $callback
  */
 public static function register($command, $callback)
 {
     self::$console->addCommand($callback, $command);
 }
Example #8
0
<?php

require_once 'vendor/autoload.php';
use ConsoleKit\Console;
use MyPatternsTest\TestAbstractFactory;
use MyPatternsTest\TestObserver;
use MyPatternsTest\TestSingleton;
$out = new Console();
$out->writeln('===============Abstract Factory==============');
TestAbstractFactory::test();
$out->writeln('==================Singleton==================');
TestSingleton::test();
$out->writeln('===================Observer==================');
TestObserver::test();
Example #9
0
 /**
  * @param $message
  */
 public function log($message)
 {
     $out = new Console();
     $out->write($message);
 }