cadre / cliadr
This package is abandoned and no longer maintained.
No replacement package was suggested.
Command line ADR implementation
0.2.0
2017-07-06 01:41 UTC
Requires (Dev)
- pds/skeleton: ^1.0.0
- phing/phing: ^2.15
- phpstan/phpstan: ^0.7.0
- phpunit/phpunit: ^6.2.3
- squizlabs/php_codesniffer: ^3.0.1
README
This is a proof of concept command line Action-Domain-Responder (ADR) implementation.
It's heavily inspired by Radar.
Example
use Aura\Cli\CliFactory; use Aura\Cli\Context; use Aura\Cli\Help; use Aura\Cli\Stdio; use Cadre\CliAdr\Boot; use Cadre\CliAdr\Input\HelpAwareInterface; require __DIR__ . '/vendor/autoload.php'; $boot = new Boot(); $adr = $boot->adr(); $adr->route('hello', function ($name) { return "Hello, {$name}"; })->input(new class implements HelpAwareInterface { public function help(Help $help) { $help->setSummary('Hello, World'); $help->setOptions([ '#name?' => 'First name [default: "World"]', ]); return $help; } public function __invoke(Context $context) { $getopt = $context->getopt([]); return [$getopt->get(2, 'World')]; } }); $factory = new CliFactory(); $context = $factory->newContext($GLOBALS); $stdio = $factory->newStdio(); exit($adr->run($context, $stdio));