Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/bombshell-dev/tab. shell autocompletions for javascript CLIs
Something went wrong. Try again.
TypeScript
12345678910111213141516171819202122232425262728import { Command } from 'commander';import tab from '../src/commander';
const program = new Command('my-cli');
program .command('greet [name]') .description('Say hello') .action(async (name) => { // async handler requires parseAsync() console.log(`Hello, ${name ?? 'world'}!`); });
const completion = tab(program);
for (const command of completion.commands.values()) { if (command.value === 'greet') { for (const [_argName, arg] of command.arguments.entries()) { arg.handler = (complete) => { complete('alice', 'Alice'); complete('bob', 'Bob'); }; } }}
await program.parseAsync();