@@ -257,16 +257,16 @@ private function getHelp(string $name, $node, ?CliHelpStyle $style = null): ?str
257257 */
258258 private function getUsage (string $ name , $ node ): ?string
259259 {
260- $ style = new CliHelpStyle (CliHelpTarget::INTERNAL , CliHelpStyle::getConsoleWidth ());
260+ $ style = new CliHelpStyle (CliHelpTarget::PLAIN , CliHelpStyle::getConsoleWidth ());
261261
262262 $ command = $ this ->getNodeCommand ($ name , $ node );
263263 $ progName = $ this ->getProgramName ();
264264
265265 if ($ command ) {
266- return Formatter:: escapeTags ( $ command ->getSynopsis ($ style )
267- . "\n\nSee ' "
268- . ($ name === '' ? "$ progName --help " : "$ progName help $ name " )
269- . "' for more information. " );
266+ return $ command ->getSynopsis ($ style )
267+ . Formatter:: escapeTags ( "\n\nSee ' "
268+ . ($ name === '' ? "$ progName --help " : "$ progName help $ name " )
269+ . "' for more information. " );
270270 }
271271
272272 if (!is_array ($ node )) {
@@ -279,16 +279,20 @@ private function getUsage(string $name, $node): ?string
279279 foreach ($ node as $ childName => $ childNode ) {
280280 $ command = $ this ->getNodeCommand (trim ("$ name $ childName " ), $ childNode );
281281 if ($ command ) {
282- $ synopses [] = $ command ->getSynopsis ($ style );
282+ $ synopsis = $ command ->getSynopsis ($ style );
283283 } elseif (is_array ($ childNode )) {
284- $ synopses [] = "$ fullName $ childName <command> " ;
284+ $ synopsis = "$ fullName $ childName <command> " ;
285+ $ synopsis = Formatter::escapeTags ($ synopsis );
286+ } else {
287+ continue ;
285288 }
289+ $ synopses [] = $ synopsis ;
286290 }
287291
288- return Formatter:: escapeTags ( implode ("\n" , $ synopses )
289- . "\n\nSee ' "
290- . Arr::implode (' ' , ["$ progName help " , $ name , '<command> ' ])
291- . "' for more information. " );
292+ return implode ("\n" , $ synopses )
293+ . Formatter:: escapeTags ( "\n\nSee ' "
294+ . Arr::implode (' ' , ["$ progName help " , $ name , '<command> ' ])
295+ . "' for more information. " );
292296 }
293297
294298 /**
@@ -319,7 +323,7 @@ public function run()
319323 if ($ arg === '--version ' && !$ args ) {
320324 $ appName = $ this ->getAppName ();
321325 $ version = Package::version (true , true );
322- Console::stdout ('__ ' . $ appName . " __ $ version" );
326+ Console::stdout ('__ ' . $ appName . ' __ ' . $ version );
323327 return $ this ;
324328 }
325329
@@ -392,7 +396,7 @@ public function run()
392396 if ($ args && $ args [0 ] === '_json_schema ' ) {
393397 array_shift ($ args );
394398 $ schema = $ command ->getJsonSchema ($ args [0 ] ?? trim ($ this ->getProgramName () . " $ name " ) . ' options ' );
395- printf ( " %s \n" , Json::prettyPrint ($ schema )) ;
399+ echo Json::prettyPrint ($ schema ) . PHP_EOL ;
396400 return $ this ;
397401 }
398402
0 commit comments