File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 11var _ = require ( 'lodash' ) ;
22
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+
318// Print help for a list of commands
419// It prints the command and its description, then all the options
520function help ( commands ) {
621 _ . each ( commands , function ( command ) {
7- console . log ( ' ' + command . name , '\t' , command . description ) ;
22+ indent_output ( 1 , command . name , command . description ) ;
823 _ . each ( command . options || [ ] , function ( option ) {
924 var after = [ ] ;
1025
@@ -14,7 +29,10 @@ function help(commands) {
1429 if ( after . length > 0 ) after = "(" + after . join ( "; " ) + ")" ;
1530 else after = "" ;
1631
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 ) ;
1836 } ) ;
1937 console . log ( '' ) ;
2038 } ) ;
You can’t perform that action at this time.
0 commit comments