Open jedwards1211 opened 4 years ago
I like the idea, but I don't think it is possible with the current API.
I guess you could do something like this:
Option 1 Option 2 Option 3 Select next page
where "select next page" could be any text, and we implemented support for when choosing any item, you can either return true to actually select the value of the item. Or you could return a promise, which would then be expected to return a new list of items.
This could be used for pagination up or down, or even more generically for some kind of arbitrarily deep folder structure.
{
type: 'autocomplete',
name: 'fruit',
suggestOnly: true,
message: 'What is your favorite fruit?',
source: searchFood,
pageSize: 4,
selectItem: function (chosenValue) {
if (chosenValue === 'folder-pictures') {
return getSubFolder(chosenValue);
} else if (chosenValue === 'next-page') {
return getNextPage();
} else {
return true;
}
}
},
}
Any thoughts?
Off the top of your head, do you know if it would be possible to implement pagination when the user scrolls down far enough in the search results? Or is it impossible to get notified by
inquirer
that that's happened?I want to make helpers for selecting AWS resources, and it would be nice to be able to use AWS pagination.
On the other hand, I want to cache and immediately show recent selections while new results are being fetched, which probably isn't possible with this...maybe I should make my own thing that doesn't rely on
inquirer
...