AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.08k stars 351 forks source link

Support having default set in input #254

Closed jack0 closed 4 years ago

jack0 commented 4 years ago

For the input and multiline prompts, it would be useful to have a configurable option to set the default in the stdin that the user can delete instead of displaying it on the same prompt line. I've looked at the code and it seems this requires some change to Renderer{}.Render. Let me know if this is not the case and there might be some better way to implement this. Thanks.

AlecAivazis commented 4 years ago

Hey @jack0!

I'm not sure i'm following what you would like to add. Can you try to elaborate a bit?

jack0 commented 4 years ago

Instead of displaying the default in the same line as the question, can we have the default value be displayed/set in the line the users type (they can use backspace to remove the default value). So it would be something like this if the default value was Alec.

? What is your name?
Alec

instead of

? What is your name? (Alec)
AlecAivazis commented 4 years ago

Ah I see. I think this should be doable by changing the template that the Select prompt uses. It should be available as survey.SelectQuestionTemplate. Let me know if you have any more questions

AlecAivazis commented 4 years ago

I'm going to close this since you haven't replied in a few months @jack0. Please feel free to commenbt here if my suggestion didn't work