Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fs: Add Exclusive parameter to Option to choose Examples only #3455

Nick Craig-Wood7ae289125260
diff --git a/fs/backend_config.go b/fs/backend_config.go
index 47fb02fbb..9516ac250 100644
--- a/fs/backend_config.go
+++ b/fs/backend_config.go
@@ -161,6 +161,7 @@ func ConfigConfirm(state string, Default bool, name string, help string) (*Confi
Value: "false",
Help: "No",
}},
+ Exclusive: true,
},
}, nil
}
@@ -182,9 +183,10 @@ func ConfigChooseFixed(state string, name string, help string, items []OptionExa
choose := &ConfigOut{
State: state,
Option: &Option{
- Name: name,
- Help: help,
- Examples: items,
+ Name: name,
+ Help: help,
+ Examples: items,
+ Exclusive: true,
},
}
choose.Option.Default = choose.Option.Examples[0].Value
diff --git a/fs/config/ui.go b/fs/config/ui.go
index c68dc183c..dbd4a512c 100644
--- a/fs/config/ui.go
+++ b/fs/config/ui.go
@@ -402,7 +402,7 @@ func ChooseOption(o *fs.Option, name string) string {
help = append(help, example.Help)
}
}
- in = Choose(o.Name, values, help, true)
+ in = Choose(o.Name, values, help, !o.Exclusive)
} else {
fmt.Printf("%s> ", o.Name)
in = ReadLine()
diff --git a/fs/fs.go b/fs/fs.go
index c0bd0e65e..0532b24ec 100644
--- a/fs/fs.go
+++ b/fs/fs.go
@@ -184,6 +184,7 @@ type Option struct {
IsPassword bool // set if the option is a password
NoPrefix bool // set if the option for this should not use the backend prefix
Advanced bool // set if this is an advanced config option
+ Exclusive bool // set if the answer can only be one of the examples
}
// BaseOption is an alias for Option used internally
diff --git a/fs/fs_test.go b/fs/fs_test.go
index 1f7aba038..4dad61f01 100644
--- a/fs/fs_test.go
+++ b/fs/fs_test.go
@@ -242,6 +242,7 @@ func TestOptionMarshalJSON(t *testing.T) {
"IsPassword": false,
"NoPrefix": false,
"Advanced": true,
+"Exclusive": false,
"DefaultStr": "false",
"ValueStr": "true",
"Type": "bool"