X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=utils.go;fp=utils.go;h=3d01346f57481a0e4089a44044250e21cbcb3587;hb=f2b2c900fcc8f02a5e532794772ed5359618c3cc;hp=65b67d3fc78ee79080b3df544b8030329999d0a2;hpb=36b8457bdd2e4fd222dec676988ffdf7f8e50f2f;p=src%2Fxds%2Fxds-cli.git diff --git a/utils.go b/utils.go index 65b67d3..3d01346 100644 --- a/utils.go +++ b/utils.go @@ -22,6 +22,7 @@ import ( "encoding/json" "fmt" "strconv" + "strings" "github.com/franciscocpg/reflectme" "github.com/iotbzh/xds-agent/lib/xaapiv1" @@ -115,3 +116,12 @@ func GetID(ctx *cli.Context) string { } return id } + +// Confirm Return true when user answer 'y' or 'yes' to a question +func Confirm(question string) bool { + var answer string + fmt.Print(question) + fmt.Scanln(&answer) + ans := strings.ToLower(strings.TrimSpace(answer)) + return (ans == "y" || ans == "yes") +}