summaryrefslogtreecommitdiffstats
path: root/utils.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2018-01-05 00:44:24 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-01-05 00:44:28 +0100
commitf2b2c900fcc8f02a5e532794772ed5359618c3cc (patch)
tree5bad4e13885bab6a8fbc327144ae1462875fdaa9 /utils.go
parent36b8457bdd2e4fd222dec676988ffdf7f8e50f2f (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.go10
1 files changed, 10 insertions, 0 deletions
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")
+}