-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path01-cli.php
More file actions
22 lines (19 loc) · 613 Bytes
/
01-cli.php
File metadata and controls
22 lines (19 loc) · 613 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
require __DIR__ . '/../vendor/autoload.php';
$router = new Clue\Commander\Router();
$router->add('exit [<code:uint>]', function (array $args) {
exit(isset($args['code']) ? $args['code'] : 0);
});
$router->add('sleep <seconds:uint>', function (array $args) {
sleep($args['seconds']);
});
$router->add('echo <words>...', function (array $args) {
echo join(' ', $args['words']) . PHP_EOL;
});
$router->add('[--help | -h]', function () use ($router) {
echo 'Usage:' . PHP_EOL;
foreach ($router->getRoutes() as $route) {
echo ' ' .$route . PHP_EOL;
}
});
$router->execArgv();