mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 09:41:44 +08: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",
|
Value: "false",
|
||||||
Help: "No",
|
Help: "No",
|
||||||
}},
|
}},
|
||||||
|
Exclusive: true,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -182,9 +183,10 @@ func ConfigChooseFixed(state string, name string, help string, items []OptionExa
|
||||||
choose := &ConfigOut{
|
choose := &ConfigOut{
|
||||||
State: state,
|
State: state,
|
||||||
Option: &Option{
|
Option: &Option{
|
||||||
Name: name,
|
Name: name,
|
||||||
Help: help,
|
Help: help,
|
||||||
Examples: items,
|
Examples: items,
|
||||||
|
Exclusive: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
choose.Option.Default = choose.Option.Examples[0].Value
|
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)
|
help = append(help, example.Help)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in = Choose(o.Name, values, help, true)
|
in = Choose(o.Name, values, help, !o.Exclusive)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%s> ", o.Name)
|
fmt.Printf("%s> ", o.Name)
|
||||||
in = ReadLine()
|
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
|
IsPassword bool // set if the option is a password
|
||||||
NoPrefix bool // set if the option for this should not use the backend prefix
|
NoPrefix bool // set if the option for this should not use the backend prefix
|
||||||
Advanced bool // set if this is an advanced config option
|
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
|
// BaseOption is an alias for Option used internally
|
||||||
|
|
|
@ -242,6 +242,7 @@ func TestOptionMarshalJSON(t *testing.T) {
|
||||||
"IsPassword": false,
|
"IsPassword": false,
|
||||||
"NoPrefix": false,
|
"NoPrefix": false,
|
||||||
"Advanced": true,
|
"Advanced": true,
|
||||||
|
"Exclusive": false,
|
||||||
"DefaultStr": "false",
|
"DefaultStr": "false",
|
||||||
"ValueStr": "true",
|
"ValueStr": "true",
|
||||||
"Type": "bool"
|
"Type": "bool"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user