admin管理员组文章数量:1399887
I have some existing syntax like:
mycommand --foo=x --bar=y
I want to migrate the syntax to:
mycommand A --foo=x --something=y
mycommand B --other=thing --another=thing
But I would like to continue to support the original syntax.
I don't think this is possible in picocli. Is that true? Are there any alternatives I should consider?
I have considered using an option instead of a subcommand. For example:
mycommand [--type=[OLD,A,B]]
With a default of OLD, if the type is omitted I could get the same behavior. However, now I have all of the options mixed together.
I considered using ArgGroups for this case, but do not see how they can be nested. That is, I cannot make a mutually exclusive argument group of dependent argument groups.
I have some existing syntax like:
mycommand --foo=x --bar=y
I want to migrate the syntax to:
mycommand A --foo=x --something=y
mycommand B --other=thing --another=thing
But I would like to continue to support the original syntax.
I don't think this is possible in picocli. Is that true? Are there any alternatives I should consider?
I have considered using an option instead of a subcommand. For example:
mycommand [--type=[OLD,A,B]]
With a default of OLD, if the type is omitted I could get the same behavior. However, now I have all of the options mixed together.
I considered using ArgGroups for this case, but do not see how they can be nested. That is, I cannot make a mutually exclusive argument group of dependent argument groups.
Share Improve this question asked Mar 24 at 19:31 Dan DietterichDan Dietterich 113 bronze badges1 Answer
Reset to default 0You can make the existing --foo
and --bar
options hidden on the top-level command. Hidden options are recognized by the parser but are not shown in the usage help message.
Then add the subcommands with their own options.
This provides a migration path to your new API.
本文标签: Can I have optional subcommands in picocliStack Overflow
版权声明:本文标题:Can I have optional subcommands in picocli? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744231565a2596361.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论