-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Autocomplete prompt #265
Conversation
this.firstRender = true; | ||
this.selected = 0; | ||
|
||
var def = this.opt.default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what to do with default for this prompt, since we have a external unknown at runtime resultset. If you want a default, maybe have the service return that choice if no match? Or should we allow a default choice(s) that is used as resultset if the search returns empty array?
Looking forward to see this getting merged. 👍 |
+1 |
Hey! Thanks for working on this. This prompt should be published as it's own npm package. Inquirer allow to be extended with custom prompt type: inquirer.registerPrompt('search', require('your-module');
inquirer.prompt({ type: 'search', ... }); This would allow you to stay the owner the that module and fixing, patching and releasing new versions of it! |
For anyone interested, I have started progress on the prompt here: https://github.com/mokkabonna/inquirer-autocomplete-prompt Not published as a npm package yet. Feedback is welcome. |
Looks like inquirer-autocomplete-prompt is now published on npm. |
I have created a POC for a autocomplete prompt. See the example for a live example.
Is this something that would be considered for inclusion in this library?
I have tried to use the api as used by other prompts although when introducing async I feel it is a bit weird. Any suggestions on how to do this instead? like the choices:
If you now define a function as your choices (as with other prompts) you have to return a inner function that gets called whenever the users input changes. This works fine, but maybe could be done better, and might be confusing.
Fake search function below (from the example):
Since the choices also aren't available at creation of the prompt it won't create a Choices object like normally, so I am creating that each time the search function is returning it's result. Is this necessary? Ideally I would just use a simple array, but there might be good reasons why you want them created as choice objects.
It is also an assumption that the search function returns a promise. I feel that promises are the way to go with async these days. Thoughts?
This PR is not complete, but meant as a proof of concept and as as place to discuss it. I have however already some tests.
I have also added a grunt develop task, just for my own sake really, I'll rebase and remove if not wanted.
The style and formatting of the code might also be a bit off, will gladly comply to whatever style is desired, just wasn't my focus right now.
As suggested here #225 I have based it of the list prompt.