-
-
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
Add handle for active prompt. #289
Conversation
Added a second commit that so that the Inquirer UI fires an event when the prompt changes. In this way, you can programmatically determine when each question gets asked. Do these changes look okay to you? |
I have a really hard time to see what you're trying to achieve. It looks to me like you want to overwrites prompts methods? If that's the case, why not overriding the prompts types with About the "next" event, why not use the reactive API? |
Thanks for your answer. Let me try to clarify. What I'm really running into is that Inquirer.js is very well designed as a UI for a CLI user, but it (intentionally, nothing wrong with it) doesn't provide much support for programmatic control of the existing UI components on the fly. Vorpal.js is built off of Inquirer, and I expose all prompts (such as lists, etc.) through it. What Vorpal does do with these however, is gives more fine-grained control of those prompts so that one can do some fancier things with them, such as:
So in summary, I'm simply trying to use Right now, Vorpal does do all of the above, however it's way too hacky and messes with your internals too much. Properly exposing the active prompt lets me do the above far more gracefully (and stably). Does this answer your question? On RxJS, I can totally do that. Just need to study up on it a bit because it's honestly still magical and new to me. :) |
You can still access the Inquirer prompts ( |
Sigh. I guess I can, however I then need to start re-writing your methods, which gets super messy, and as soon as you do an All I'd really like to do is expose a UI Component (not change its methods) while it is being prompted, and then I can cleanly handle the rest. If you don't like the way I did it, I can totally change it to whatever you see as the best way to go about it: just let me know. Any chance we can just do this? 😃 |
👍 I too wish Inquirer were more easily programmatically extendable. |
@SBoudrias @sindresorhus perhaps we could discuss a roadmap in this direction that we all can agree on and that doesn't mess with Simon's original goals in making Inquirer. I've had a lot of experience now messing with Inquirer's internals, so I could lay out what I think would improve it in a programmatic sense, and wouldn't mind helping get done whatever we agree on. What do you guys think? |
👍 I want things like this to be possible: #46 |
👍 I'm currently finalizing the
Most of these dig deep into the internals of |
Just put together better descriptions of the functionality I'd love to see in Inquirer. (Need to work more on the |
@SBoudrias I managed to figure out a workaround for now on this issue, so I'm going to close the PR. You don't seem to excited about it haha. Anyway, if you ever want to get around to making Inquirer more programmatically accessible, let me know and I'll gladly help! |
@dthree that'd be great. I'd just like it to match closer the api design style of Inquirer. |
When
inquirer.prompt
is called, theUI
object is returned. However, in the course of cycling through prompts, the currently active prompt is never exposed to either theUI
object norinquirer
itself.I added a simple handle that cleans itself up, and exposed a public function to the
UI
object returned in a prompt, so that one can programatically assess and handle the current prompt.Usage example:
This would be tremendously helpful for programmatic use of Inquirer.js as I can then hook in keypress events and control the active prompt in a proper fashion. This is needed to finish this pjt:
https://github.com/vorpaljs/vorpal-less
:)