zk/adapter/term/prompt.go

21 lines
434 B
Go
Raw Normal View History

package term
2021-01-23 20:15:17 +00:00
import (
survey "github.com/AlecAivazis/survey/v2"
2021-01-23 20:15:17 +00:00
)
// Confirm is a shortcut to prompt a yes/no question to the user.
func (t *Terminal) Confirm(msg string, defaultAnswer bool) (confirmed, skipped bool) {
if !t.IsInteractive() {
return defaultAnswer, true
}
confirmed = false
prompt := &survey.Confirm{
Message: msg,
Default: defaultAnswer,
}
survey.AskOne(prompt, &confirmed)
return confirmed, false
2021-01-23 20:15:17 +00:00
}