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
command.MarkFlagRequired Does not look at inherited flags #921
Comments
command.Mark(Persistent)FlagRequired
Does not look at inherited flags
This issue is being marked as stale due to a long period of inactivity |
Sounds like the root issue is #961 . Not closing this as duplicate since this expands that issue slightly by pointing out the effect this has on auto-completion. |
Agree that its frustrating and confusing to have to differentiate the two the whole time; to the local function it shouldn't really matter where the flag came from, just that it is required for the command. |
This problem is made a bit worse by the cobra-cli's default way of using Would be really nice to see cobra-cli move to a centralized set of |
I believe this is broken behavior, but the documentation isn't entirely clear. It is also not the same as #723.
The functions
command.MarkFlagRequired
andcommand.MarkPersistentFlagRequired
callreturn MarkFlagRequired(flags, name)
withFlags()
andPersistentFlags()
, respectively. That causes them to not be aware of any inherited flags on the command.The documentation for
MarkFlagRequired
:Which reads as though it shouldn't distinguish between inherited flags and local flags. Otherwise, you have to re-declare flags at the subcommand that you want to mark them as required.
As a workaround, we're using our own utility function:
It seems like the library methods should be amended to call
c.mergePersistentFlags()
.The text was updated successfully, but these errors were encountered: