Closed mistkafka closed 6 years ago
This plugin supports the choice format that inquirer support:
{
name: 'Displayed in list',
value: {}, // your object
short: 'Displayed when answered'
}
https://github.com/SBoudrias/Inquirer.js#objects
choices: (Array|Function) Choices array or a function returning a choices array. If defined as a function, the first parameter will be the current inquirer session answers. Array values can be simple strings, or objects containing a name (to display in list), a value (to save in the answers hash) and a short (to display after selection) properties. The choices array can also contain a Separator.
Just make sure your source function return a promise that resolves to a list with objects that matches the one above.
It would be great if this were mentioned in the docs.
sometimes, we fetch data(a list for object) to auto-complete-select, but which key in each object should to be the "Display Name"?
For Now: I need store the data's key mapping, after user select a item, use regular express to get the key, and get the result. It's too troublesome.