Added an execute() method to context to catch unhandled commands

This commit is contained in:
Christopher Vagnetoft
2016-11-19 14:18:53 +01:00
parent 7bfd8453e7
commit 43a6475192
3 changed files with 43 additions and 0 deletions

20
examples/catchall.php Normal file
View File

@ -0,0 +1,20 @@
<?php
require_once __DIR__."/../vendor/autoload.php";
use NoccyLabs\Shell\Shell;
use NoccyLabs\Shell\Context;
class CatchAllContext extends Context
{
public function execute($cmd, ...$arg)
{
printf("Executing: %s %s\n", $cmd, join(" ",$arg));
return true;
}
}
$myShell = new Shell();
$myShell->setPrompt("test>");
$myShell->pushContext(new CatchAllContext());
$myShell->run();