-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Using altsrc + required flags on Command doesn't seem to work #1725
Comments
@zllovesuki @tg123 The problem is the ordering. The required flags are checked prior to the "Before" handler running. @zllovesuki in your case you could have a Before handler in App to initialize the altsrc. That should fix your issue. |
@dearchap if I do have the handler in Before to have handle altsrc in App, does that affect other Subcommands? Also, that means I need to specify the config file flag in the App but no Command, which may cause issues |
When you say it affects subcommands it will if they define altsrc flags as well. |
Hi, I suppose the ordering refers to here, and wonder if reversing it would be reasonable. Since if I put a main command in |
It might be fine but at this point v2 is strictly in maintenance mode. No feature updates or anything. We could consider this for v3. See #833 |
Also #1273 . Will close this issue. |
My urfave/cli version is
v2.25.1
Checklist
Dependency Management
Describe the bug
If the altsrc flag is required on the Command instead of the App, it will say that the required flag is not set
To reproduce
Example code:
Observed behavior
Expected behavior
Flags parsed from file correctly
Run
go version
and paste its output hereRun
go env
and paste its output hereThe text was updated successfully, but these errors were encountered: