cmd: factor FlagName into fs.Option #2541

This commit is contained in:
Nick Craig-Wood 2018-09-24 21:27:30 +01:00
parent 5fde7d8b12
commit e7e467fb3a
2 changed files with 15 additions and 4 deletions

View file

@ -447,10 +447,7 @@ func AddBackendFlags() {
}
done[opt.Name] = struct{}{}
// Make a flag from each option
name := strings.Replace(opt.Name, "_", "-", -1) // convert snake_case to kebab-case
if !opt.NoPrefix {
name = fsInfo.Prefix + "-" + name
}
name := opt.FlagName(fsInfo.Prefix)
found := pflag.CommandLine.Lookup(name) != nil
if !found {
// Take first line of help only