|
1
|
|
|
#!/usr/bin/php |
|
2
|
|
|
<?php |
|
3
|
|
|
|
|
4
|
|
|
require __DIR__ . '/../vendor/autoload.php'; |
|
5
|
|
|
|
|
6
|
|
|
use Stefaminator\Cli\App; |
|
7
|
|
|
use Stefaminator\Cli\Cmd; |
|
8
|
|
|
use Stefaminator\Cli\Color; |
|
9
|
|
|
|
|
10
|
|
|
(new class extends App { |
|
11
|
|
|
|
|
12
|
|
|
public function setup(): Cmd { |
|
13
|
|
|
return ( |
|
14
|
|
|
new class extends Cmd { |
|
15
|
|
|
|
|
16
|
|
|
public function init(): void { |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function run(): void { |
|
20
|
|
|
$this->runHelp(); |
|
21
|
|
|
} |
|
22
|
|
|
}) |
|
23
|
|
|
->addChild((new class('show') extends Cmd { |
|
24
|
|
|
|
|
25
|
|
|
public function init(): void { |
|
26
|
|
|
|
|
27
|
|
|
$this |
|
28
|
|
|
->setDescription( |
|
29
|
|
|
'This command is used to show something. Take a look at the subcommands.' |
|
30
|
|
|
); |
|
31
|
|
|
|
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function run(): void { |
|
35
|
|
|
$this->runHelp(); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
}) |
|
39
|
|
|
->addChild((new class('hello') extends Cmd { |
|
40
|
|
|
|
|
41
|
|
|
public function init(): void { |
|
42
|
|
|
|
|
43
|
|
|
$this |
|
44
|
|
|
->setDescription( |
|
45
|
|
|
'Displays hello world.' |
|
46
|
|
|
) |
|
47
|
|
|
->addOption('h|help', [ |
|
48
|
|
|
'description' => 'Displays the command help.' |
|
49
|
|
|
]) |
|
50
|
|
|
->addOption('name:', [ |
|
51
|
|
|
'description' => 'Name option. This option requires a value.', |
|
52
|
|
|
'isa' => 'string', |
|
53
|
|
|
'default' => 'World' |
|
54
|
|
|
]); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function run(): void { |
|
58
|
|
|
|
|
59
|
|
|
if ($this->hasProvidedOption('help')) { |
|
60
|
|
|
$this->runHelp(); |
|
61
|
|
|
return; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$name = $this->getProvidedOption('name'); |
|
65
|
|
|
|
|
66
|
|
|
self::eol(); |
|
67
|
|
|
self::echo(sprintf('Hello %s!', $name), Color::FOREGROUND_COLOR_CYAN); |
|
68
|
|
|
self::eol(); |
|
69
|
|
|
self::eol(); |
|
70
|
|
|
} |
|
71
|
|
|
})) |
|
72
|
|
|
->addChild((new class('phpversion') extends Cmd { |
|
73
|
|
|
|
|
74
|
|
|
public function init(): void { |
|
75
|
|
|
|
|
76
|
|
|
$this |
|
77
|
|
|
->addOption('h|help', [ |
|
78
|
|
|
'description' => 'Displays the command help.' |
|
79
|
|
|
]) |
|
80
|
|
|
->setDescription( |
|
81
|
|
|
'Displays the current php version of your cli.' |
|
82
|
|
|
); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function run(): void { |
|
86
|
|
|
|
|
87
|
|
|
if ($this->hasProvidedOption('help')) { |
|
88
|
|
|
$this->runHelp(); |
|
89
|
|
|
return; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
self::eol(); |
|
93
|
|
|
self::echo(' Your PHP version is:', Color::FOREGROUND_COLOR_YELLOW); |
|
94
|
|
|
self::eol(); |
|
95
|
|
|
self::echo(' ' . PHP_VERSION); |
|
96
|
|
|
self::eol(); |
|
97
|
|
|
self::eol(); |
|
98
|
|
|
} |
|
99
|
|
|
})) |
|
100
|
|
|
); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
})->run(); |
|
104
|
|
|
|