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

本文标签: Can I have optional subcommands in picocliStack Overflow