Initial commit
This commit is contained in:
		
							
								
								
									
										46
									
								
								examples/flinger.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								examples/flinger.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
<?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();
 | 
			
		||||
		Reference in New Issue
	
	Block a user