Skip to content

Commit 7d6f7a2

Browse files
committed
fix option completion
1 parent 8a03ae7 commit 7d6f7a2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/t.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,7 @@ export class RootCommand extends Command {
293293
command.options
294294
);
295295

296-
this.completions = toComplete.includes('=')
297-
? suggestions.map((s) => ({
298-
value: `${optionName}=${s.value}`,
299-
description: s.description,
300-
}))
301-
: suggestions;
296+
this.completions = suggestions;
302297
}
303298
return;
304299
}
@@ -428,7 +423,14 @@ export class RootCommand extends Command {
428423
seen.add(comp.value);
429424
return true;
430425
})
431-
.filter((comp) => comp.value.startsWith(toComplete))
426+
.filter((comp) => {
427+
if (toComplete.includes('=')) {
428+
// for --option=value format, extract the value part after =
429+
const [, valueToComplete] = toComplete.split('=');
430+
return comp.value.startsWith(valueToComplete);
431+
}
432+
return comp.value.startsWith(toComplete);
433+
})
432434
.forEach((comp) =>
433435
console.log(`${comp.value}\t${comp.description ?? ''}`)
434436
);
@@ -541,7 +543,6 @@ export class RootCommand extends Command {
541543

542544
const t = new RootCommand();
543545

544-
// TODO: re-check the below
545546
export function script(shell: string, name: string, executable: string) {
546547
t.setup(name, executable, shell);
547548
}

0 commit comments

Comments
 (0)