diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-01-05 00:44:24 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-01-05 00:44:28 +0100 |
commit | f2b2c900fcc8f02a5e532794772ed5359618c3cc (patch) | |
tree | 5bad4e13885bab6a8fbc327144ae1462875fdaa9 /utils.go | |
parent | 36b8457bdd2e4fd222dec676988ffdf7f8e50f2f (diff) |
Add confirmation before deleting a project or a sdk.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'utils.go')
-rw-r--r-- | utils.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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") +} |