-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
OnlyValidArgs does not take into account the new ValidArgsFunction #1298
Comments
Thanks @davidovich for bringing this up. Of course you make a valid point. I hesitated about this question when implementing #1035.
On the other hand including a verification of
And say the argument is not valid, Cobra will print a generic "invalid argument" message. By instead letting With that in mind, I am of the opinion we should not include But we should probably document this behaviour better. What do you think? |
@marckhouzam Yes, I believe this could be prohibitive to always call the function, but in some local scenarios, I could also be fine performance wise. A configuration option could control if the But I also agree that cobra can only do so much generically, so aside from that, a better documentation regarding this fact would be a gain IMHO. |
This is not correct. In #841,
Therefore, with #841, you should be able to define |
This issue is being marked as stale due to a long period of inactivity |
Based on the last comment; its just waiting for the #841 to merge. Leaving open until then. |
@johnSchnake my understanding is that this issue is unrelated to #841 indeed. #841 was created before In #841, |
When you use the new recommended
ValidArgsFunction
, you loose the possibility to use theOnlyValidArgs
validation function. As the documentation says thatValidArgs
andValidArgsFunction
are mutually exclusive, programs that use theOnlyValidArgs
validator break when transitioning toValidArgsFunction
.As both config options are mutually exclusive, the
OnlyValidArgs
function should use the the result ofValidArgsFunction
if it is available.I believe this is a regression that appeared when implementing the ValidArgsFunction in #1035, which states that it is a dynamic version of
ValidArgs
, hence should support the validator also.Note that #841 moves the
OnlyValidArgs
to a private function, and will suffer from the same problem.The text was updated successfully, but these errors were encountered: