Open
Description
It would be nice if we could generate dynamic completions/choices
on-the-fly when the user presses Tab in their shell. I would like to complete a positional argument or option value that's not from a hardcoded list, but eg loaded from a database.
For example, something like:
yargs(…).command('foo <title>', '…', (yargs) =>
yargs.positional('title', {
choices: async (str) => {
const results = await database.findMany({ where: { title: { startsWith: str }}})
return results //, an array of strings
},
}),
async (argv) => { … }
);
Typing app foo ba
Tab would invoke choices('ba')
, which could return ['bar']
, and ultimately the shell would complete the title
argument with a value found in a database.
Activity