File tree Expand file tree Collapse file tree 4 files changed +27
-39
lines changed
Expand file tree Collapse file tree 4 files changed +27
-39
lines changed Original file line number Diff line number Diff line change @@ -85,25 +85,21 @@ export default async function tab(
8585 break ;
8686 }
8787 default : {
88- try {
89- assertDoubleDashes ( instance . name ) ;
88+ assertDoubleDashes ( instance . name ) ;
9089
91- const args : string [ ] = extra [ '--' ] || [ ] ;
92- instance . showHelpOnExit = false ;
90+ const args : string [ ] = extra [ '--' ] || [ ] ;
91+ instance . showHelpOnExit = false ;
9392
94- // Parse current command context
95- instance . unsetMatchedCommand ( ) ;
96- instance . parse ( [ execPath , processArgs [ 0 ] , ...args ] , {
97- run : false ,
98- } ) ;
93+ // Parse current command context
94+ instance . unsetMatchedCommand ( ) ;
95+ instance . parse ( [ execPath , processArgs [ 0 ] , ...args ] , {
96+ run : false ,
97+ } ) ;
9998
100- // const matchedCommand = instance.matchedCommand?.name || '';
101- // const potentialCommand = args.join(' ')
102- // console.log(potentialCommand)
103- return completion . parse ( args ) ;
104- } catch ( error ) {
105- return ;
106- }
99+ // const matchedCommand = instance.matchedCommand?.name || '';
100+ // const potentialCommand = args.join(' ')
101+ // console.log(potentialCommand)
102+ return completion . parse ( args ) ;
107103 }
108104 }
109105 } ) ;
Original file line number Diff line number Diff line change @@ -187,21 +187,17 @@ export default async function tab<TArgs extends ArgsDef>(
187187 break ;
188188 }
189189 default : {
190- try {
191- assertDoubleDashes ( name ) ;
192-
193- const extra = ctx . rawArgs . slice ( ctx . rawArgs . indexOf ( '--' ) + 1 ) ;
194- // const args = (await resolve(instance.args))!;
195- // const parsed = parseArgs(extra, args);
196- // TODO: this is not ideal at all
197- // const matchedCommand = parsed._.join(' ').trim(); //TODO: this was passed to parse line 170
198- // TODO: `command lint i` does not work because `lint` and `i` are potential commands
199- // instead the potential command should only be `lint`
200- // and `i` is the to be completed part
201- return completion . parse ( extra ) ;
202- } catch ( error ) {
203- return ;
204- }
190+ assertDoubleDashes ( name ) ;
191+
192+ const extra = ctx . rawArgs . slice ( ctx . rawArgs . indexOf ( '--' ) + 1 ) ;
193+ // const args = (await resolve(instance.args))!;
194+ // const parsed = parseArgs(extra, args);
195+ // TODO: this is not ideal at all
196+ // const matchedCommand = parsed._.join(' ').trim(); //TODO: this was passed to parse line 170
197+ // TODO: `command lint i` does not work because `lint` and `i` are potential commands
198+ // instead the potential command should only be `lint`
199+ // and `i` is the to be completed part
200+ return completion . parse ( extra ) ;
205201 }
206202 }
207203 } ,
Original file line number Diff line number Diff line change @@ -80,14 +80,10 @@ export default function tab(instance: CommanderCommand): Completion {
8080 break ;
8181 }
8282 default : {
83- try {
84- assertDoubleDashes ( programName ) ;
83+ assertDoubleDashes ( programName ) ;
8584
86- // Parse current command context for autocompletion
87- return completion . parse ( extra ) ;
88- } catch ( error ) {
89- return ;
90- }
85+ // Parse current command context for autocompletion
86+ return completion . parse ( extra ) ;
9187 }
9288 }
9389 } ) ;
Original file line number Diff line number Diff line change @@ -23,6 +23,6 @@ export function assertDoubleDashes(programName: string = 'cli'): void {
2323 if ( dashDashIndex === - 1 ) {
2424 const errorMessage = `Error: You need to use -- to separate completion arguments.\nExample: ${ programName } complete -- <args>` ;
2525 console . error ( errorMessage ) ;
26- throw new Error ( 'Missing -- separator' ) ;
26+ process . exit ( 1 ) ;
2727 }
2828}
You can’t perform that action at this time.
0 commit comments