aboutsummaryrefslogtreecommitdiff
path: root/auth/input.go
diff options
context:
space:
mode:
Diffstat (limited to 'auth/input.go')
-rw-r--r--auth/input.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/auth/input.go b/auth/input.go
index aa56f52..42b5907 100644
--- a/auth/input.go
+++ b/auth/input.go
@@ -54,11 +54,12 @@ func secretInput(label, errMessage string) string {
os.Exit(1)
}
- return res
+ // trim leading and trailing whitespaces
+ return strings.TrimSpace(res)
}
// ask yes/no with no as default
-func confirmInput(label string) bool {
+func confirmInput(label string, def bool) bool {
validResponses := []string{"y", "yes", "n", "no", ""}
validate := func(input string) error {
@@ -89,9 +90,14 @@ func confirmInput(label string) bool {
os.Exit(1)
}
- if res == "y" || res == "yes" {
+ resp := strings.TrimSpace(strings.ToLower(res))
+ if resp == "y" || resp == "yes" {
return true
}
+ if resp == "" {
+ return def
+ }
+
return false
}