2021-01-23 20:29:22 +00:00
|
|
|
package term
|
2021-01-23 20:15:17 +00:00
|
|
|
|
|
|
|
import (
|
2021-02-07 18:53:51 +00:00
|
|
|
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.
|
2021-02-10 19:53:25 +00:00
|
|
|
func (t *Terminal) Confirm(msg string, defaultAnswer bool) (confirmed, skipped bool) {
|
|
|
|
if !t.IsInteractive() {
|
|
|
|
return defaultAnswer, true
|
|
|
|
}
|
|
|
|
|
|
|
|
confirmed = false
|
2021-02-07 18:53:51 +00:00
|
|
|
prompt := &survey.Confirm{
|
|
|
|
Message: msg,
|
2021-02-10 19:53:25 +00:00
|
|
|
Default: defaultAnswer,
|
2021-02-07 18:53:51 +00:00
|
|
|
}
|
|
|
|
survey.AskOne(prompt, &confirmed)
|
2021-02-10 19:53:25 +00:00
|
|
|
return confirmed, false
|
2021-01-23 20:15:17 +00:00
|
|
|
}
|