Conditions | 1 |
Paths | 1 |
Total Lines | 41 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | #!/usr/bin/php |
||
14 | |||
15 | public function setup(): Cmd { |
||
16 | return Cmd::root() |
||
17 | ->setRunner( |
||
18 | (new class extends CmdRunner { |
||
19 | |||
20 | public function run(): void { |
||
21 | $this->getCmd()->help(); |
||
22 | } |
||
23 | }) |
||
24 | ) |
||
25 | ->addSubCmd( |
||
26 | Cmd::extend('show') |
||
27 | ->setDescription('This command is used to show something. Take a look at the subcommands.') |
||
28 | ->setRunner( |
||
29 | (new class extends CmdRunner { |
||
30 | |||
31 | public function run(): void { |
||
32 | $this->getCmd()->help(); |
||
33 | } |
||
34 | }) |
||
35 | ) |
||
36 | ->addSubCmd( |
||
37 | Cmd::extend('hello') |
||
38 | ->setDescription('Displays hello world.') |
||
39 | ->addOption('name:', [ |
||
40 | 'description' => 'Name option. This option requires a value.', |
||
41 | 'isa' => 'string', |
||
42 | 'default' => 'World' |
||
43 | ]) |
||
44 | ->setRunner( |
||
45 | (new class extends CmdRunner { |
||
46 | |||
47 | public function run(): void { |
||
48 | |||
49 | $cmd = $this->getCmd(); |
||
50 | |||
51 | $name = $cmd->getProvidedOption('name'); |
||
52 | |||
53 | self::eol(); |
||
54 | self::echo(sprintf('Hello %s!', $name), Color::FOREGROUND_COLOR_CYAN); |
||
55 | self::eol(); |
||
83 |