AlecAivazis / survey

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

Add text prompt feature #161

Closed rmfish closed 5 years ago

rmfish commented 5 years ago

Add a text prompt prints message without any answer.

160

AlecAivazis commented 5 years ago

Hey @rmfish - thanks for submitting this.

I'm a bit uneasy with changing the interface for Prompt since it would be an API breaking change for survey. Given that you can pull this off with AskOne or other hacky approaches like printing from Transform, i'm inclined to think that this doesn't add enough to the collection of default prompts and is better kept in userland.

For your usecase, it seems very likely that the message you want to show the user depends on the answers to the other prompts which means Text either needs to take a function of the previous values to define its message, or it would need to be created in an AskOne anyway so that Message can refer to the struct holding the answers.

AlecAivazis commented 5 years ago

Hey @rmfish i appreciate you also adding support for a go module. Would yu mind opening that up in a second PR so I can merge that bit ASAP?

rmfish commented 5 years ago

Hey @rmfish i appreciate you also adding support for a go module. Would yu mind opening that up in a second PR so I can merge that bit ASAP?

OK :)

rmfish commented 5 years ago

Hey @rmfish - thanks for submitting this.

I'm a bit uneasy with changing the interface for Prompt since it would be an API breaking change for survey. Given that you can pull this off with AskOne or other hacky approaches like printing from Transform, i'm inclined to think that this doesn't add enough to the collection of default prompts and is better kept in userland.

For your usecase, it seems very likely that the message you want to show the user depends on the answers to the other prompts which means Text either needs to take a function of the previous values to define its message, or it would need to be created in an AskOne anyway so that Message can refer to the struct holding the answers.

Sorry, I was not realized that it's bad to change the api of Prompt. There are indeed other better ways to resolve my problems. I close this PR, thx.