mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 08:23:47 +01:00
fs: Add Exclusive parameter to Option to choose Examples only #3455
This commit is contained in:
parent
99caf79ffe
commit
7ae2891252
@ -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
|
||||
|
@ -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()
|
||||
|
1
fs/fs.go
1
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
|
||||
|
@ -242,6 +242,7 @@ func TestOptionMarshalJSON(t *testing.T) {
|
||||
"IsPassword": false,
|
||||
"NoPrefix": false,
|
||||
"Advanced": true,
|
||||
"Exclusive": false,
|
||||
"DefaultStr": "false",
|
||||
"ValueStr": "true",
|
||||
"Type": "bool"
|
||||
|
Loading…
Reference in New Issue
Block a user