1414use Inhere \Console \Contract \CommandInterface ;
1515use Inhere \Console \IO \Input ;
1616use Inhere \Console \IO \Output ;
17- use Inhere \Console \Router ;
1817use Inhere \Console \Util \FormatUtil ;
1918use Inhere \Console \Util \Show ;
2019use Toolkit \Cli \ColorTag ;
3938use const PHP_EOL ;
4039use const PHP_OS ;
4140use const PHP_VERSION ;
41+ use const STR_PAD_LEFT ;
4242
4343/**
4444 * Trait ApplicationHelpTrait
@@ -61,32 +61,46 @@ trait ApplicationHelpTrait
6161 */
6262 public function showVersionInfo (): void
6363 {
64- $ os = PHP_OS ;
65- $ date = date ('Y.m.d ' );
64+ $ this ->fire (ConsoleEvent::BEFORE_RENDER_APP_VERSION , $ this );
65+
66+ Show::aList ($ this ->buildVersionInfo (), '' , [
67+ 'leftChar ' => '' ,
68+ 'sepChar ' => ' : ' ,
69+ 'keyPadPos ' => STR_PAD_LEFT ,
70+ ]);
71+ }
72+
73+ /**
74+ * @return string[]
75+ */
76+ protected function buildVersionInfo (): array
77+ {
6678 $ logo = '' ;
79+ $ date = date ('Y.m.d ' );
6780 $ name = $ this ->getParam ('name ' , 'Console Application ' );
6881
69- $ version = $ this ->getParam ('version ' , 'Unknown ' );
70- $ publishAt = $ this ->getParam ('publishAt ' , 'Unknown ' );
71- $ updateAt = $ this ->getParam ('updateAt ' , 'Unknown ' );
72- $ phpVersion = PHP_VERSION ;
82+ $ osName = PHP_OS ;
83+ $ phpVer = PHP_VERSION ;
84+ $ version = $ this ->getParam ('version ' , 'Unknown ' );
7385
74- $ this ->fire (ConsoleEvent::BEFORE_RENDER_APP_VERSION , $ this );
86+ $ updateAt = $ this ->getParam ('updateAt ' , 'Unknown ' );
87+ $ publishAt = $ this ->getParam ('publishAt ' , 'Unknown ' );
7588
7689 if ($ logoTxt = $ this ->getLogoText ()) {
7790 $ logo = ColorTag::wrap ($ logoTxt , $ this ->getLogoStyle ());
7891 }
7992
80- /** @var Output $out */
81- $ out = $ this ->output ;
82- $ out ->aList ([
93+ $ info = [
8394 "$ logo \n <info> $ name</info>, Version <comment> $ version</comment> \n" ,
84- 'System Info ' => "PHP version <info> $ phpVersion </info>, on <info> $ os </info> system " ,
95+ 'System Info ' => "PHP version <info> $ phpVer </info>, on <info> $ osName </info> system " ,
8596 'Application Info ' => "Update at <info> $ updateAt</info>, publish at <info> $ publishAt</info>(current $ date) " ,
86- ], '' , [
87- 'leftChar ' => '' ,
88- 'sepChar ' => ' : '
89- ]);
97+ ];
98+
99+ if ($ hUrl = $ this ->getParam ('homepage ' )) {
100+ $ info ['Homepage URL ' ] = $ hUrl ;
101+ }
102+
103+ return $ info ;
90104 }
91105
92106 /**
@@ -183,8 +197,6 @@ public function showCommandList(): void
183197
184198 $ this ->logf (Console::VERB_DEBUG , 'Display the application commands list ' );
185199
186- /** @var Output $output */ // $output = $this->output;
187- /** @var Router $router */
188200 $ router = $ this ->getRouter ();
189201
190202 $ hasGroup = $ hasCommand = false ;
@@ -306,7 +318,6 @@ protected function dumpAutoCompletion(string $shellEnv, array $data): void
306318 $ input = $ this ->input ;
307319 /** @var Output $output */
308320 $ output = $ this ->output ;
309- /** @var Router $router */
310321 $ router = $ this ->getRouter ();
311322
312323 // info
0 commit comments