php-shell/examples/flinger.php
Christopher Vagnetoft e6f6fbe3d3 Initial commit
2016-04-13 03:19:22 +02:00

47 lines
842 B
PHP

<?php
require_once __DIR__."/../vendor/autoload.php";
use NoccyLabs\Shell\Shell;
class MyShell extends Shell
{
protected $params;
protected function setParam($key, $value=null)
{
$this->params[$key] = $value;
$this->writeln(" ** {$key} = {$value}");
}
protected function configure(array $config)
{
$this->addCommand("set", [$this,"setParam"]);
$this->addCommand("exit", [$this,"stop"]);
}
protected function getPrompt()
{
return "flinger: ";
}
protected function onUpdate()
{
static $lt;
$t = floor(microtime(true));
if ($t > $lt) {
$lt = $t + 5;
echo date("Y-m-d h:i:s")."\n";
}
}
protected function onInput($buffer)
{
}
}
$myShell = new MyShell();
$myShell->run();