@@ -60,63 +60,68 @@ main.subCommands = {
6060 lint : lintCommand ,
6161} as Record < string , CommandDef < ArgsDef > > ;
6262
63- const completion = await tab ( main ) ;
64-
65- for ( const command of completion . commands . values ( ) ) {
66- if ( command . name === 'lint' ) {
67- command . handler = ( ) => {
68- return [
69- { value : 'main.ts' , description : 'Main file' } ,
70- { value : 'index.ts' , description : 'Index file' } ,
71- ] ;
72- } ;
73- }
74-
75- for ( const [ o , config ] of command . options . entries ( ) ) {
76- if ( o === '--port' ) {
77- config . handler = ( ) => {
78- return [
79- { value : '3000' , description : 'Development server port' } ,
80- { value : '8080' , description : 'Alternative port' } ,
81- ] ;
82- } ;
83- }
84- if ( o === '--host' ) {
85- config . handler = ( ) => {
63+ const completion = await tab ( main , {
64+ subCommands : {
65+ lint : {
66+ handler ( ) {
8667 return [
87- { value : 'localhost ' , description : 'Localhost ' } ,
88- { value : '0.0.0.0 ' , description : 'All interfaces ' } ,
68+ { value : 'main.ts ' , description : 'Main file ' } ,
69+ { value : 'index.ts ' , description : 'Index file ' } ,
8970 ] ;
90- } ;
91- }
92- if ( o === '--config' ) {
93- config . handler = ( ) => {
71+ } ,
72+ } ,
73+ dev : {
74+ options : {
75+ port : {
76+ handler ( ) {
77+ return [
78+ { value : '3000' , description : 'Development server port' } ,
79+ { value : '8080' , description : 'Alternative port' } ,
80+ ] ;
81+ } ,
82+ } ,
83+ host : {
84+ handler ( ) {
85+ return [
86+ { value : 'localhost' , description : 'Localhost' } ,
87+ { value : '0.0.0.0' , description : 'All interfaces' } ,
88+ ] ;
89+ } ,
90+ } ,
91+ } ,
92+ } ,
93+ } ,
94+ options : {
95+ config : {
96+ handler ( ) {
9497 return [
9598 { value : 'vite.config.ts' , description : 'Vite config file' } ,
9699 { value : 'vite.config.js' , description : 'Vite config file' } ,
97100 ] ;
98- } ;
99- }
100- if ( o === '-- mode' ) {
101- config . handler = ( ) => {
101+ } ,
102+ } ,
103+ mode : {
104+ handler ( ) {
102105 return [
103106 { value : 'development' , description : 'Development mode' } ,
104107 { value : 'production' , description : 'Production mode' } ,
105108 ] ;
106- } ;
107- }
108- if ( o === '-- logLevel' ) {
109- config . handler = ( ) => {
109+ } ,
110+ } ,
111+ logLevel : {
112+ handler ( ) {
110113 return [
111114 { value : 'info' , description : 'Info level' } ,
112115 { value : 'warn' , description : 'Warn level' } ,
113116 { value : 'error' , description : 'Error level' } ,
114117 { value : 'silent' , description : 'Silent level' } ,
115118 ] ;
116- } ;
117- }
118- }
119- }
119+ } ,
120+ } ,
121+ } ,
122+ } ) ;
123+
124+ completion ;
120125
121126const cli = createMain ( main ) ;
122127
0 commit comments