mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 02:14:42 +01:00
cmd: make backend env vars show in help as the defaults for backend flags
Before this change RCLONE_DRIVE_CHUNK_SIZE=111M rclone help flags | grep drive-chunk-size Would show the default value, not the setting of RCLONE_DRIVE_CHUNK_SIZE as the non backend flags do. This change makes it work as expected by setting the default of the option to the environment variable. Fixes #4659
This commit is contained in:
parent
70f92fd6b3
commit
72083c65ad
@ -513,7 +513,7 @@ func AddBackendFlags() {
|
||||
if opt.IsPassword {
|
||||
help += " (obscured)"
|
||||
}
|
||||
flag := pflag.CommandLine.VarPF(opt, name, opt.ShortOpt, help)
|
||||
flag := flags.VarPF(pflag.CommandLine, opt, name, opt.ShortOpt, help)
|
||||
if _, isBool := opt.Default.(bool); isBool {
|
||||
flag.NoOptDefVal = "true"
|
||||
}
|
||||
|
@ -156,6 +156,15 @@ func FVarP(flags *pflag.FlagSet, value pflag.Value, name, shorthand, usage strin
|
||||
setDefaultFromEnv(flags, name)
|
||||
}
|
||||
|
||||
// VarPF defines a flag which can be overridden by an environment variable
|
||||
//
|
||||
// It is a thin wrapper around pflag.VarPF
|
||||
func VarPF(flags *pflag.FlagSet, value pflag.Value, name, shorthand, usage string) *pflag.Flag {
|
||||
flag := flags.VarPF(value, name, shorthand, usage)
|
||||
setDefaultFromEnv(flags, name)
|
||||
return flag
|
||||
}
|
||||
|
||||
// StringArrayP defines a flag which can be overridden by an environment variable
|
||||
//
|
||||
// It sets one value only - command line flags can be used to set more.
|
||||
|
Loading…
Reference in New Issue
Block a user