@@ -20,10 +20,10 @@ export type OptionHandler = (
2020 options : OptionsMap
2121) => void ;
2222
23- export type Completion = {
23+ export interface Completion {
2424 description ?: string ;
2525 value : string ;
26- } ;
26+ }
2727
2828export type ArgumentHandler = (
2929 this : Argument ,
@@ -214,8 +214,7 @@ export class RootCommand extends Command {
214214
215215 private shouldCompleteFlags (
216216 lastPrevArg : string | undefined ,
217- toComplete : string ,
218- endsWithSpace : boolean
217+ toComplete : string
219218 ) : boolean {
220219 if ( toComplete . startsWith ( '-' ) ) {
221220 return true ;
@@ -244,10 +243,7 @@ export class RootCommand extends Command {
244243 return false ;
245244 }
246245
247- private shouldCompleteCommands (
248- toComplete : string ,
249- endsWithSpace : boolean
250- ) : boolean {
246+ private shouldCompleteCommands ( toComplete : string ) : boolean {
251247 return ! toComplete . startsWith ( '-' ) ;
252248 }
253249
@@ -256,7 +252,6 @@ export class RootCommand extends Command {
256252 command : Command ,
257253 previousArgs : string [ ] ,
258254 toComplete : string ,
259- endsWithSpace : boolean ,
260255 lastPrevArg : string | undefined
261256 ) {
262257 // Handle flag value completion
@@ -350,12 +345,7 @@ export class RootCommand extends Command {
350345 }
351346
352347 // positional argument completion
353- private handlePositionalCompletion (
354- command : Command ,
355- previousArgs : string [ ] ,
356- toComplete : string ,
357- endsWithSpace : boolean
358- ) {
348+ private handlePositionalCompletion ( command : Command , previousArgs : string [ ] ) {
359349 // current argument position (subtract command name)
360350 const commandParts = command . value . split ( ' ' ) . length ;
361351 const currentArgIndex = Math . max ( 0 , previousArgs . length - commandParts ) ;
@@ -437,12 +427,11 @@ export class RootCommand extends Command {
437427 const [ matchedCommand ] = this . matchCommand ( previousArgs ) ;
438428 const lastPrevArg = previousArgs [ previousArgs . length - 1 ] ;
439429
440- if ( this . shouldCompleteFlags ( lastPrevArg , toComplete , endsWithSpace ) ) {
430+ if ( this . shouldCompleteFlags ( lastPrevArg , toComplete ) ) {
441431 this . handleFlagCompletion (
442432 matchedCommand ,
443433 previousArgs ,
444434 toComplete ,
445- endsWithSpace ,
446435 lastPrevArg
447436 ) ;
448437 } else {
@@ -461,16 +450,11 @@ export class RootCommand extends Command {
461450 }
462451 }
463452
464- if ( this . shouldCompleteCommands ( toComplete , endsWithSpace ) ) {
453+ if ( this . shouldCompleteCommands ( toComplete ) ) {
465454 this . handleCommandCompletion ( previousArgs , toComplete ) ;
466455 }
467456 if ( matchedCommand && matchedCommand . arguments . size > 0 ) {
468- this . handlePositionalCompletion (
469- matchedCommand ,
470- previousArgs ,
471- toComplete ,
472- endsWithSpace
473- ) ;
457+ this . handlePositionalCompletion ( matchedCommand , previousArgs ) ;
474458 }
475459 }
476460
0 commit comments