New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to explicitly set flag to 'zero' value using altsrc #1395
Comments
we meet the same issue. should drop if value { condition |
The same too but it took me a while to figure out where my bug came from 😅 Is there any plan to fix this? |
@klueska sorry for my long delay! Given some recent related work by @joeycumines at the top-level package, I'd love to see if there's a solution to |
@meatballhat I am probably lacking some context, but this appears to be an issue stemming from the use of a default value guard, to check if values are set. It seems to me that following through on #1376, and removing the guards for all cases (as I think @klueska and @sjp00556 are suggesting) would resolve this issue. Side note, #1376 is a breaking change. I'd have instead used an error as a sentinel, to indicate not set. This would avoid implementers of While I'm on the topic, I'd suggest establishing clear (and ideally consistent) rules regarding how the different input sources are combined. Notably, in some cases the "is set" check for environment variables include similar guards, checking against an empty string. In #1409, I opted to keep this behavior for Idk what Line 226 in c114605
|
Mmmm actually, addressing this issue (w/o a breaking change) is more difficult than I'd thought. Regardless of the mechanism used to indicate "not set", removal of the default value checks will still (potentially) break input source implementations that don't support said mechanism. Even assuming Alternate solution: Leave the default value guards in, but only use them if the Disclaimer: I only just noticed the |
@joeycumines I hope I'm understanding you correctly, but making https://cli.urfave.org/v2/#precedence In any case, I think I'm in favor of:
|
My bad, when I said
I wasn't including default. Sorry, that was unclear. |
No worries! Thank you! |
@klueska Are you able to test with latest code ? There have been lots of fixes in that area since this issue was raised. |
Not present in latest releases. |
The following check prevents one from explicitly setting a
bool
flag tofalse
when using analtsrc
input:cli/altsrc/flag.go
Line 129 in c114605
This can cause issues (for example) if the default value from the command line is
true
and you want to explicitly set the flag tofalse
in a config file.This is not just true for
bool
s (as the link points to), but other flag types as well(most notably
string
with its check on""
).The text was updated successfully, but these errors were encountered: