1
mirror of https://github.com/rclone/rclone synced 2024-11-29 07:55:12 +01:00

rclone config: when choosing from a list, allow the value to be entered

This commit is contained in:
Nick Craig-Wood 2017-01-29 15:51:26 +00:00
parent db0b93c0ad
commit 2192805360

View File

@ -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) {