mirror of
https://github.com/rclone/rclone
synced 2024-12-23 14:23:44 +01:00
flags: improve error message when reading environment vars #4888
The message now includes the flag name to help the user work out what is happening. Invalid value for environment variable "RCLONE_VERSION" when setting default for --version: strconv.ParseBool: parsing "yes": invalid syntax
This commit is contained in:
parent
629c0d0f65
commit
060642ad14
@ -19,13 +19,13 @@ func setDefaultFromEnv(flags *pflag.FlagSet, name string) {
|
||||
if found {
|
||||
flag := flags.Lookup(name)
|
||||
if flag == nil {
|
||||
log.Fatalf("Couldn't find flag %q", name)
|
||||
log.Fatalf("Couldn't find flag --%q", name)
|
||||
}
|
||||
err := flag.Value.Set(newValue)
|
||||
if err != nil {
|
||||
log.Fatalf("Invalid value for environment variable %q: %v", key, err)
|
||||
log.Fatalf("Invalid value for environment variable %q when setting default for --%s: %v", key, name, err)
|
||||
}
|
||||
fs.Debugf(nil, "Set default for %q from %q to %q (%v)", name, key, newValue, flag.Value)
|
||||
fs.Debugf(nil, "Set default for --%q from %q to %q (%v)", name, key, newValue, flag.Value)
|
||||
flag.DefValue = newValue
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user