aboutsummaryrefslogtreecommitdiffstats
path: root/utils.go
diff options
context:
space:
mode:
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")
+}