@@ -17,12 +17,13 @@ const cliTools = ['citty', 'cac', 'commander'];
1717
1818describe . each ( cliTools ) ( 'cli completion tests for %s' , ( cliTool ) => {
1919 // For Commander, we need to skip most of the tests since it handles completion differently
20- const shouldSkipTest = ( cliTool === 'commander' ) ;
21-
20+ const shouldSkipTest = cliTool === 'commander' ;
21+
2222 // Commander uses a different command structure for completion
23- const commandPrefix = cliTool === 'commander'
24- ? `pnpm tsx examples/demo.${ cliTool } .ts complete`
25- : `pnpm tsx examples/demo.${ cliTool } .ts complete --` ;
23+ const commandPrefix =
24+ cliTool === 'commander'
25+ ? `pnpm tsx examples/demo.${ cliTool } .ts complete`
26+ : `pnpm tsx examples/demo.${ cliTool } .ts complete --` ;
2627
2728 it . runIf ( ! shouldSkipTest ) ( 'should complete cli options' , async ( ) => {
2829 const output = await runCommand ( `${ commandPrefix } ` ) ;
@@ -87,25 +88,28 @@ describe.each(cliTools)('cli completion tests for %s', (cliTool) => {
8788 } ) ;
8889 } ) ;
8990
90- describe . runIf ( ! shouldSkipTest ) ( 'edge case completions for end with space' , ( ) => {
91- it ( 'should suggest port values if user ends with space after `--port`' , async ( ) => {
92- const command = `${ commandPrefix } serve --port ""` ;
93- const output = await runCommand ( command ) ;
94- expect ( output ) . toMatchSnapshot ( ) ;
95- } ) ;
91+ describe . runIf ( ! shouldSkipTest ) (
92+ 'edge case completions for end with space' ,
93+ ( ) => {
94+ it ( 'should suggest port values if user ends with space after `--port`' , async ( ) => {
95+ const command = `${ commandPrefix } serve --port ""` ;
96+ const output = await runCommand ( command ) ;
97+ expect ( output ) . toMatchSnapshot ( ) ;
98+ } ) ;
9699
97- it ( "should keep suggesting the --port option if user typed partial but didn't end with space" , async ( ) => {
98- const command = `${ commandPrefix } serve --po` ;
99- const output = await runCommand ( command ) ;
100- expect ( output ) . toMatchSnapshot ( ) ;
101- } ) ;
100+ it ( "should keep suggesting the --port option if user typed partial but didn't end with space" , async ( ) => {
101+ const command = `${ commandPrefix } serve --po` ;
102+ const output = await runCommand ( command ) ;
103+ expect ( output ) . toMatchSnapshot ( ) ;
104+ } ) ;
102105
103- it ( "should suggest port values if user typed `--port=` and hasn't typed a space or value yet" , async ( ) => {
104- const command = `${ commandPrefix } serve --port=` ;
105- const output = await runCommand ( command ) ;
106- expect ( output ) . toMatchSnapshot ( ) ;
107- } ) ;
108- } ) ;
106+ it ( "should suggest port values if user typed `--port=` and hasn't typed a space or value yet" , async ( ) => {
107+ const command = `${ commandPrefix } serve --port=` ;
108+ const output = await runCommand ( command ) ;
109+ expect ( output ) . toMatchSnapshot ( ) ;
110+ } ) ;
111+ }
112+ ) ;
109113
110114 describe . runIf ( ! shouldSkipTest ) ( 'short flag handling' , ( ) => {
111115 it ( 'should handle short flag value completion' , async ( ) => {
@@ -133,34 +137,28 @@ describe.each(cliTools)('cli completion tests for %s', (cliTool) => {
133137 } ) ;
134138 } ) ;
135139
136- describe . runIf ( ! shouldSkipTest && cliTool !== 'citty' ) ( 'positional argument completions' , ( ) => {
137- it (
138- 'should complete multiple positional arguments when ending with space' ,
139- async ( ) => {
140+ describe . runIf ( ! shouldSkipTest && cliTool !== 'citty' ) (
141+ 'positional argument completions' ,
142+ ( ) => {
143+ it ( 'should complete multiple positional arguments when ending with space' , async ( ) => {
140144 const command = `${ commandPrefix } lint ""` ;
141145 const output = await runCommand ( command ) ;
142146 expect ( output ) . toMatchSnapshot ( ) ;
143- }
144- ) ;
147+ } ) ;
145148
146- it (
147- 'should complete multiple positional arguments when ending with part of the value' ,
148- async ( ) => {
149+ it ( 'should complete multiple positional arguments when ending with part of the value' , async ( ) => {
149150 const command = `${ commandPrefix } lint ind` ;
150151 const output = await runCommand ( command ) ;
151152 expect ( output ) . toMatchSnapshot ( ) ;
152- }
153- ) ;
153+ } ) ;
154154
155- it (
156- 'should complete single positional argument when ending with space' ,
157- async ( ) => {
155+ it ( 'should complete single positional argument when ending with space' , async ( ) => {
158156 const command = `${ commandPrefix } lint main.ts ""` ;
159157 const output = await runCommand ( command ) ;
160158 expect ( output ) . toMatchSnapshot ( ) ;
161- }
162- ) ;
163- } ) ;
159+ } ) ;
160+ }
161+ ) ;
164162} ) ;
165163
166164// Add specific tests for Commander
@@ -179,7 +177,7 @@ describe('commander specific tests', () => {
179177 const output1 = await runCommand ( command1 ) ;
180178 expect ( output1 ) . toContain ( 'deploy' ) ;
181179 expect ( output1 ) . toContain ( 'Deploy the application' ) ;
182-
180+
183181 // Then we need to check if the deploy command has subcommands
184182 // We can check this by running the deploy command with --help
185183 const command2 = `pnpm tsx examples/demo.commander.ts deploy --help` ;
0 commit comments