Skip to content

Commit b23edf4

Browse files
committed
update: add version display for cli app
1 parent 4ec2f5b commit b23edf4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/App.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ class App
5454
* @var array
5555
*/
5656
private $metas = [
57-
'name' => 'My application',
58-
'desc' => 'My command line application',
57+
'name' => 'My application',
58+
'desc' => 'My command line application',
59+
'version' => '0.2.1'
5960
];
6061

6162
/**
@@ -361,9 +362,13 @@ public function displayHelp(string $err = ''): void
361362

362363
// help
363364
$desc = ucfirst($this->metas['desc']);
365+
if ($ver = $this->metas['version']) {
366+
$desc .= "(<red>v$ver</red>)";
367+
}
368+
364369
$usage = "<cyan>{$this->script} COMMAND -h</cyan>";
365370

366-
$help = "$desc\n<comment>Usage:</comment> $usage\n<comment>Commands:</comment>\n";
371+
$help = "$desc\n\n<comment>Usage:</comment> $usage\n<comment>Commands:</comment>\n";
367372
$data = $this->messages;
368373
ksort($data);
369374

0 commit comments

Comments
 (0)