Replies: 1 comment
-
For arguments, we support For commands, we currently do not provide a way to do this. We offer a You could handle this in validation code after parsing. This would also make the intent in the code clearer as you |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
One can currently add:
to a subcommand or an argument to hide it from the usage. But in that case, the command or argument can still be used. I was looking for a way to hide a subcommand under some dynamic conditions and make them not work in that case.
There is a skip attribute that makes a subcommand not added to the
Command
at all, which is not clear from the documentation what it's useful for, but it doesn't support dynamic conditions.I successfully used that attribute to do what I'm asking for, albeit with extra steps: I had to define another Type that manually adds the subcommand in a CommandFactory impl, and with a FromArgsMatches delegating to the FromArgsMatches from the command containing the skipped subcommand, and a fallback to the subcommand itself.
Is there something simpler? If not, should there?
Beta Was this translation helpful? Give feedback.
All reactions