From 21928053608f5560b80e5e5aaa6e718e9f3ba4ad Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 29 Jan 2017 15:51:26 +0000 Subject: [PATCH] rclone config: when choosing from a list, allow the value to be entered --- fs/config.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/config.go b/fs/config.go index 7d88a1c3c..fbf345571 100644 --- a/fs/config.go +++ b/fs/config.go @@ -685,11 +685,11 @@ func Confirm() bool { // Choose one of the defaults or type a new string if newOk is set func Choose(what string, defaults, help []string, newOk bool) string { - fmt.Printf("Choose a number from below") + valueDescripton := "an existing" if newOk { - fmt.Printf(", or type in your own value") + valueDescripton = "your own" } - fmt.Println() + fmt.Printf("Choose a number from below, or type in %s value\n", valueDescripton) for i, text := range defaults { var lines []string if help != nil { @@ -728,6 +728,11 @@ func Choose(what string, defaults, help []string, newOk bool) string { if newOk { return result } + for _, v := range defaults { + if result == v { + return result + } + } continue } if i >= 1 && i <= len(defaults) {