@@ -4,7 +4,7 @@ import * as fish from './fish';
44import * as powershell from './powershell' ;
55import type { CAC } from 'cac' ;
66import { Completion } from './index' ;
7- import { CompletionConfig , noopHandler } from './shared' ;
7+ import { CompletionConfig , noopHandler , requireDashDashSeparator } from './shared' ;
88
99const execPath = process . execPath ;
1010const processArgs = process . argv . slice ( 1 ) ;
@@ -24,10 +24,6 @@ export default async function tab(
2424) {
2525 const completion = new Completion ( ) ;
2626
27- // a hidden flag to track if -- is there in the raw arguments? we might need a better way to do this?
28- const dashDashIndex = process . argv . indexOf ( '--' ) ;
29- const wasDashDashProvided = dashDashIndex !== - 1 ;
30-
3127 // Add all commands and their options
3228 for ( const cmd of [ instance . globalCommand , ...instance . commands ] ) {
3329 if ( cmd . name === 'complete' ) continue ; // Skip completion command
@@ -89,12 +85,10 @@ export default async function tab(
8985 break ;
9086 }
9187 default : {
92- if ( ! wasDashDashProvided ) {
93- console . error (
94- 'Error: You need to use -- to separate completion arguments'
95- ) ;
88+ if ( ! requireDashDashSeparator ( instance . name ) ) {
9689 return ;
9790 }
91+
9892 const args : string [ ] = extra [ '--' ] || [ ] ;
9993 instance . showHelpOnExit = false ;
10094
0 commit comments