Can I have optional subcommands in picocli? - Stack Overflow

I have some existing syntax like:mycommand --foo=x --bar=yI want to migrate the syntax to:mycommand A

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

You 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744231565a4564277.html

相关推荐

  • Can I have optional subcommands in picocli? - Stack Overflow

    I have some existing syntax like:mycommand --foo=x --bar=yI want to migrate the syntax to:mycommand A

    8天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信