File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import program from 'commander';
22import pjson from '../../package.json' ;
33import chalk from 'chalk' ;
44
5+ const availableCommands = [ 'init' , 'list' , 'search' , 'info' ] ;
6+
57program
68 . version ( pjson . version )
79 . option ( '-v, --version' , 'check version' )
@@ -11,13 +13,16 @@ program
1113 . command ( 'search [term]' , 'Search for MERN variant' )
1214 . command ( 'info [term]' , 'View details of a MERN variant' )
1315 . arguments ( '<command>' )
14- . action ( ( cmd ) => {
15- program . outputHelp ( )
16- console . log ( ` ` + chalk . yellow ( `\n Unknown command ${ chalk . green ( cmd ) } ` ) )
17- console . log ( )
18- } )
1916 . parse ( process . argv ) ;
2017
18+ if ( program . args . length >= 1 ) {
19+ if ( ! availableCommands . includes ( program . args [ 0 ] ) ) {
20+ program . outputHelp ( )
21+ console . log ( ` ` + chalk . red ( `\n Unknown command ${ chalk . yellow ( program . args [ 0 ] ) } .` ) )
22+ console . log ( )
23+ }
24+ }
25+
2126if ( ! program . args . length ) {
2227 program . help ( ) ;
2328}
You can’t perform that action at this time.
0 commit comments