-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmd
More file actions
41 lines (34 loc) · 1.01 KB
/
cmd
File metadata and controls
41 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Andrey\Cli\Examples\BasicHandler;
use Exception;
use InvalidArgumentException;
use Andrey\Cli\Types\Command;
use Andrey\Cli\Types\Context;
use Andrey\Cli\App;
use Andrey\Cli\Types\ConsoleLevel;
require './../../vendor/autoload.php';
try {
$app = new App(
appName: 'MyApp',
description: 'My app has a cool description',
cmd: 'php cmd',
params: [],
commands: [
new Command(
key: 'run',
description: 'This action will run soon',
service: [
'handler' => static function(Context $context): void {
App::console('It is so easy!!!');
},
],
),
],
);
$app->run($argv);
} catch (InvalidArgumentException $e) {
App::console($e->getMessage(), ConsoleLevel::ERROR);
} catch (Exception $e) {
App::console($e->getMessage(), ConsoleLevel::ERROR);
App::console(print_r($e, true), ConsoleLevel::ERROR);
}