From f2b2c900fcc8f02a5e532794772ed5359618c3cc Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Fri, 5 Jan 2018 00:44:24 +0100 Subject: Add confirmation before deleting a project or a sdk. Signed-off-by: Sebastien Douheret --- utils.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'utils.go') 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") +} -- cgit 1.2.3-korg