@@ -37,34 +37,38 @@ const completion = await tab(cli);
3737// custom config for options
3838for ( const command of completion . commands . values ( ) ) {
3939 for ( const [ optionName , config ] of command . options . entries ( ) ) {
40- if ( optionName === '--port' ) {
41- config . handler = ( ) => {
42- return [
43- { value : '3000' , description : 'Default port' } ,
44- { value : '8080' , description : 'Alternative port' } ,
45- ] ;
40+ if ( optionName === 'port' ) {
41+ config . handler = function ( complete ) {
42+ complete ( '3000' , 'Default port' ) ;
43+ complete ( '8080' , 'Alternative port' ) ;
4644 } ;
4745 }
4846
49- if ( optionName === '--mode' ) {
50- config . handler = ( ) => {
51- return [
52- { value : 'development' , description : 'Development mode' } ,
53- { value : 'production' , description : 'Production mode' } ,
54- { value : 'test' , description : 'Test mode' } ,
55- ] ;
47+ if ( optionName === 'mode' ) {
48+ config . handler = function ( complete ) {
49+ complete ( 'development' , 'Development mode' ) ;
50+ complete ( 'production' , 'Production mode' ) ;
51+ complete ( 'test' , 'Test mode' ) ;
5652 } ;
5753 }
5854
59- if ( optionName === '--config' ) {
60- config . handler = ( ) => {
61- return [
62- { value : 'config.json' , description : 'JSON config file' } ,
63- { value : 'config.js' , description : 'JavaScript config file' } ,
64- ] ;
55+ if ( optionName === 'config' ) {
56+ config . handler = function ( complete ) {
57+ complete ( 'config.json' , 'JSON config file' ) ;
58+ complete ( 'config.js' , 'JavaScript config file' ) ;
6559 } ;
6660 }
6761 }
6862}
6963
64+ // for root command options
65+ for ( const [ optionName , config ] of completion . options . entries ( ) ) {
66+ if ( optionName === 'config' ) {
67+ config . handler = function ( complete ) {
68+ complete ( 'config.json' , 'JSON config file' ) ;
69+ complete ( 'config.js' , 'JavaScript config file' ) ;
70+ } ;
71+ }
72+ }
73+
7074cli . parse ( ) ;
0 commit comments