Keeping question at the end of console
Hi,
Is there any way to make inquirer question persistently at the end of console output? I have script with multiple asynchronous operations outputting to console, but I would like to have inquirer question persistent at the end of console no matter what - so users won't miss it even if a lot of additional text is logged.
Alternatively can I force rerendering from code? It is done internally whenever there is some user interaction with console - I would like to simply have such hook from script.
Thanks, Rafal
Hey @PaQ666,
This isn't something I've tried making work. You could get some inspiration from the BottomBar module in this repository - but it's not working out of the box with prompts.
Would love to see this feature too, it's getting very messy when other console logs are displayed in the prompt.
Any update on this issue?
@adamreisnz it's not something I plan working on myself. I'm happy to help review the concept (before any PR) if someone wants to spend time working on such a feature.
Would you be open to adding a new method to inquirer, e.g. something like .log() which could be used to log a simple line of text to the console, which would then push the current prompt down again? This log could then be used instead of regular console.log commands, which tend to log data all over (or under) the inquirer interface.
Could you provide an example how an end-user would use inquirer.log()? I'm not sure I fully understand in which context this is necessary.
Yes, I'll provide a use case demo in a minute
Right, that minute took longer than anticipated.
Here's how I use inquirer:

We have a little diagnostics script which allows us to connect to our hardware via serial port and send a variety of commands, as per above.
Whenever we send a command, we output the JSON string that gets sent and anything that is received on the serial port, for debugging purposes and diagnostics:

Depending on the timing, these JSON logs can show up all throughout the inquirer interface, because a regular console.log doesn't know what inquirer is doing:

In this latter example, the moment I navigate commands, the green received JSON response is overwritten by inquirer, because it overwrites the line in the console.
So what I'm asking for, is a method on Inquirer to log a line to the console, and then have that line be logged above the last inquirer prompt, so that it persists i n the console and won't be erased by subsequent prompts.
Much like happened in my first example:

These two lines are persisted, but the green JSON from my second example has disappeared:

So what I'm asking for is a way to "safely" log generic contents to the console, while an inquirer prompt is active.
Hope this makes sense.
Hey @SBoudrias, I have a somewhat similar issue. In my case, the previous prompt is shown again in terminal after console.log or this.log, hence the same question is printed twice -
- Once, when it is supposed to, when user has to answer it.
- Second, after user enters the answer, I validate it asynchronously and log something to terminal, the question is printed again WITH the answer and the subsequent question.
I don't want this, I want a prompt to be shown only once.

Here is another example of this issue:

I have a inquirer prompt asking for a user selection, then returning a response from a database, then looping. The prompts are overwriting the response tables.