mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-29 13:27:03 +02:00
Allow default value for boolean select
Default for both service delete conformation and disabling Maloja autofix is now "no".
This commit is contained in:
parent
6c1cf2101d
commit
76fd7cfeb4
3 changed files with 17 additions and 8 deletions
|
@ -60,15 +60,20 @@ func PromptSecret(opt models.BackendOption) (string, error) {
|
|||
}
|
||||
|
||||
func PromptBool(opt models.BackendOption) (bool, error) {
|
||||
return PromptYesNo(opt.Label)
|
||||
return PromptYesNo(opt.Label, opt.Default == "true")
|
||||
}
|
||||
|
||||
func PromptYesNo(label string) (bool, error) {
|
||||
func PromptYesNo(label string, defaultValue bool) (bool, error) {
|
||||
yes := i18n.Tr("Yes")
|
||||
no := i18n.Tr("No")
|
||||
selected := 1
|
||||
if defaultValue {
|
||||
selected = 0
|
||||
}
|
||||
sel := promptui.Select{
|
||||
Label: label,
|
||||
Items: []string{yes, no},
|
||||
Label: label,
|
||||
Items: []string{yes, no},
|
||||
CursorPos: selected,
|
||||
}
|
||||
_, val, err := sel.Run()
|
||||
return val == yes, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue