You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)=>{constresults=awaitdatabase.findMany({where: {title: {startsWith: str}}})returnresults//, an array of strings},}),async(argv)=>{…});
Typing app foo baTab would invoke choices('ba'), which could return ['bar'], and ultimately the shell would complete the title argument with a value found in a database.
The text was updated successfully, but these errors were encountered:
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:
Typing
app foo ba
Tab would invokechoices('ba')
, which could return['bar']
, and ultimately the shell would complete thetitle
argument with a value found in a database.The text was updated successfully, but these errors were encountered: