File tree 1 file changed +20
-2
lines changed
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 1
1
var _ = require ( 'lodash' ) ;
2
2
3
+ // Helper function for print help
4
+ // indented output by spaces
5
+ function indent_output ( n , name , description ) {
6
+ if ( ! n ) {
7
+ n = 0 ;
8
+ }
9
+
10
+ console . log (
11
+ _ . repeat ( ' ' , n )
12
+ + name
13
+ + _ . repeat ( ' ' , 32 - n * 4 - name . length )
14
+ + description
15
+ ) ;
16
+ }
17
+
3
18
// Print help for a list of commands
4
19
// It prints the command and its description, then all the options
5
20
function help ( commands ) {
6
21
_ . each ( commands , function ( command ) {
7
- console . log ( ' ' + command . name , '\t' , command . description ) ;
22
+ indent_output ( 1 , command . name , command . description ) ;
8
23
_ . each ( command . options || [ ] , function ( option ) {
9
24
var after = [ ] ;
10
25
@@ -14,7 +29,10 @@ function help(commands) {
14
29
if ( after . length > 0 ) after = "(" + after . join ( "; " ) + ")" ;
15
30
else after = "" ;
16
31
17
- console . log ( ' --' + option . name , '\t' , option . description , after ) ;
32
+ var optname = '--' ;
33
+ if ( typeof option . defaults === 'boolean' ) optname += '[no-]' ;
34
+ optname += option . name ;
35
+ indent_output ( 2 , optname , option . description + ' ' + after ) ;
18
36
} ) ;
19
37
console . log ( '' ) ;
20
38
} ) ;
You can’t perform that action at this time.
0 commit comments