@@ -70,7 +70,7 @@ public function setHelp($help)
7070 }
7171
7272 /**
73- * Sets the help text for the tools commands itself
73+ * Sets the help text for the tool's commands
7474 *
7575 * @param string $help
7676 */
@@ -79,6 +79,16 @@ public function setCommandHelp($help)
7979 $ this ->setup ['' ]['commandhelp ' ] = $ help ;
8080 }
8181
82+ /**
83+ * Sets the help text for the tools commands itself
84+ *
85+ * @param boolean $compact
86+ */
87+ public function setCompactHelp (bool $ compact =true )
88+ {
89+ $ this ->setup ['' ]['compacthelp ' ] = $ compact ;
90+ }
91+
8292 /**
8393 * Register the names of arguments for help generation and number checking
8494 *
@@ -346,6 +356,8 @@ public function help()
346356 $ hascommands = (count ($ this ->setup ) > 1 );
347357 $ commandhelp = $ this ->setup ["" ]["commandhelp " ]
348358 ?: 'This tool accepts a command as first parameter as outlined below: ' ;
359+ $ compacthelp = $ this ->setup ["" ]["compacthelp " ] ?: false ;
360+
349361 foreach ($ this ->setup as $ command => $ config ) {
350362 $ hasopts = (bool )$ this ->setup [$ command ]['opts ' ];
351363 $ hasargs = (bool )$ this ->setup [$ command ]['args ' ];
@@ -378,7 +390,9 @@ public function help()
378390 }
379391 $ text .= ' ' . $ out ;
380392 }
381- $ text .= "\n" ;
393+ if (!$ compacthelp ) {
394+ $ text .= "\n" ;
395+ }
382396
383397 // usage or command intro
384398 if ($ this ->setup [$ command ]['help ' ]) {
@@ -392,7 +406,9 @@ public function help()
392406 // option description
393407 if ($ hasopts ) {
394408 if (!$ command ) {
395- $ text .= "\n" ;
409+ if (!$ compacthelp ) {
410+ $ text .= "\n" ;
411+ }
396412 $ text .= $ this ->colors ->wrap ('OPTIONS: ' , Colors::C_BROWN );
397413 }
398414 $ text .= "\n" ;
@@ -411,12 +427,15 @@ public function help()
411427 $ name .= ' < ' . $ opt ['needsarg ' ] . '> ' ;
412428 }
413429
430+ if (!$ compacthelp ) {
431+ $ text .= "\n" ;
432+ }
433+
414434 $ text .= $ tf ->format (
415435 array ($ mv , '30% ' , '* ' ),
416436 array ('' , $ name , $ opt ['help ' ]),
417437 array ('' , 'green ' , '' )
418438 );
419- $ text .= "\n" ;
420439 }
421440 }
422441
@@ -447,7 +466,9 @@ public function help()
447466 array ($ mv , '* ' ),
448467 array ('' , $ commandhelp )
449468 );
450- $ text .= "\n" ;
469+ if (!$ compacthelp ) {
470+ $ text .= "\n" ;
471+ }
451472 }
452473 }
453474
0 commit comments