@@ -70,7 +70,7 @@ public function setHelp($help)
70
70
}
71
71
72
72
/**
73
- * Sets the help text for the tools commands itself
73
+ * Sets the help text for the tool's commands
74
74
*
75
75
* @param string $help
76
76
*/
@@ -79,6 +79,16 @@ public function setCommandHelp($help)
79
79
$ this ->setup ['' ]['commandhelp ' ] = $ help ;
80
80
}
81
81
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
+
82
92
/**
83
93
* Register the names of arguments for help generation and number checking
84
94
*
@@ -346,6 +356,8 @@ public function help()
346
356
$ hascommands = (count ($ this ->setup ) > 1 );
347
357
$ commandhelp = $ this ->setup ["" ]["commandhelp " ]
348
358
?: 'This tool accepts a command as first parameter as outlined below: ' ;
359
+ $ compacthelp = $ this ->setup ["" ]["compacthelp " ] ?: false ;
360
+
349
361
foreach ($ this ->setup as $ command => $ config ) {
350
362
$ hasopts = (bool )$ this ->setup [$ command ]['opts ' ];
351
363
$ hasargs = (bool )$ this ->setup [$ command ]['args ' ];
@@ -378,21 +390,26 @@ public function help()
378
390
}
379
391
$ text .= ' ' . $ out ;
380
392
}
381
- $ text .= "\n" ;
393
+ if (!$ compacthelp ) {
394
+ $ text .= "\n" ;
395
+ }
382
396
383
397
// usage or command intro
384
398
if ($ this ->setup [$ command ]['help ' ]) {
385
399
$ text .= "\n" ;
386
400
$ text .= $ tf ->format (
387
401
array ($ mv , '* ' ),
388
- array ('' , $ this ->setup [$ command ]['help ' ] . "\n" )
402
+ array ('' , $ this ->setup [$ command ]['help ' ]
403
+ . (!$ compacthelp ?: "\n" ))
389
404
);
390
405
}
391
406
392
407
// option description
393
408
if ($ hasopts ) {
394
409
if (!$ command ) {
395
- $ text .= "\n" ;
410
+ if (!$ compacthelp ) {
411
+ $ text .= "\n" ;
412
+ }
396
413
$ text .= $ this ->colors ->wrap ('OPTIONS: ' , Colors::C_BROWN );
397
414
}
398
415
$ text .= "\n" ;
@@ -411,12 +428,15 @@ public function help()
411
428
$ name .= ' < ' . $ opt ['needsarg ' ] . '> ' ;
412
429
}
413
430
431
+ if (!$ compacthelp ) {
432
+ $ text .= "\n" ;
433
+ }
434
+
414
435
$ text .= $ tf ->format (
415
436
array ($ mv , '30% ' , '* ' ),
416
437
array ('' , $ name , $ opt ['help ' ]),
417
438
array ('' , 'green ' , '' )
418
439
);
419
- $ text .= "\n" ;
420
440
}
421
441
}
422
442
@@ -447,7 +467,9 @@ public function help()
447
467
array ($ mv , '* ' ),
448
468
array ('' , $ commandhelp )
449
469
);
450
- $ text .= "\n" ;
470
+ if (!$ compacthelp ) {
471
+ $ text .= "\n" ;
472
+ }
451
473
}
452
474
}
453
475
0 commit comments