Ai
1 Star 0 Fork 0

smartos-club/triton-kubernetes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
confirm_prompt.go 711 Bytes
一键复制 编辑 原始数据 按行查看 历史
package util
import (
"fmt"
"github.com/manifoldco/promptui"
)
// Returns true if user selects 'Yes'. false if 'No'
func PromptForConfirmation(label, selected string) (bool, error) {
confirmOptions := []struct {
Name string
Value bool
}{
{"Yes", true},
{"No", false},
}
confirmPrompt := promptui.Select{
Label: label,
Items: confirmOptions,
Templates: &promptui.SelectTemplates{
Label: "{{ . }}?",
Active: fmt.Sprintf("%s {{ .Name | underline }}", promptui.IconSelect),
Inactive: " {{.Name}}",
Selected: fmt.Sprintf(" %s? {{.Name}}", selected),
},
}
i, _, err := confirmPrompt.Run()
if err != nil {
return false, err
}
return confirmOptions[i].Value, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/smartos-club/triton-kubernetes.git
git@gitee.com:smartos-club/triton-kubernetes.git
smartos-club
triton-kubernetes
triton-kubernetes
v0.9.1

搜索帮助