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

How to default a confirmation? #294

Closed richardltc closed 3 years ago

richardltc commented 4 years ago

Is there a way that we can default a confirmation to either true or false?

Thanks

MarkusFreitag commented 4 years ago

Yes, you can set the default when creating a survey.Confirm component like this:


  var answer bool
  prompt := &survey.Confirm{
    Message: "Do you like cookies?",
    Default: true, // default to true/yes because who doesn't like them
  }
  survey.AskOne(prompt, &answer)
infalmo commented 3 years ago

Close this since its resolved? @richardltc

richardltc commented 3 years ago

Yes please. All sorted now.

Thanks

On Mon, 5 Oct 2020, 17:45 infixint943, notifications@github.com wrote:

Close this since its resolved? @richardltc https://github.com/richardltc

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AlecAivazis/survey/issues/294#issuecomment-703752381, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKXFD3U5KGEEKEDENLJKSQ3SJHZ4DANCNFSM4OWTRPKA .

richardltc commented 3 years ago

Thank you, and sorry for they very later reply.

Richard

On Mon, 13 Jul 2020 at 10:15, Markus Freitag notifications@github.com wrote:

Yes, you can set the default when creating a survey.Confirm component like this:

var answer bool prompt := &survey.Confirm{ Message: "Do you like cookies?", Default: true, // default to true/yes because who doesn't like them } survey.AskOne(prompt, &answer)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AlecAivazis/survey/issues/294#issuecomment-657432774, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKXFD3WZCOJORG5MTTLS4Z3R3LGEJANCNFSM4OWTRPKA .