cbeust / jcommander

Command line parsing framework for Java
Apache License 2.0
1.94k stars 332 forks source link

Does Jcommander support parse args into multiple sub command #570

Open ruanwenjun opened 10 months ago

ruanwenjun commented 10 months ago

In my usage, I hope to parse the input args into some sub command. e.g. The input looks like

-i iArgs -o oArgs -p pArgs

And I have Three sub command ICommand, OCommand, PCommand, I hope JCommand receive args, and can return ICommand, OCommand, PCommand or return only one command which order is higher.

mkarg commented 10 months ago

Have you read the docs? Have you tried it out?

ruanwenjun commented 10 months ago

Have you read the docs? Have you tried it out?

I have read the doc, find I can add sub command by following way

image

In this way, I need to create subcommand object first and check each after parsed, I am not sure if there exist other better way.

mkarg commented 10 months ago

Can you please rewrite your test in a way that demonstrates what you like to do instead of the above code, and can you please outline why your intended solution would be easier/better/superior? That makes it easier for us to understand if/why/how to change JCommander's API. :-)

BTW, there is no need to paste JPGs. In fact, it makes it harder for us to copy-paste your demo code. If you could use backticks to markup plain text we would be able to try out your code without the need to transcripe it from the JPG. Thanks.

mkarg commented 4 months ago

@ruanwenjun Still looking forward to receive your answer in the current discussion! :-)