cbeust / jcommander

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

Subcommands #445

Open nanodeath opened 6 years ago

nanodeath commented 6 years ago

Hey, so, I have a case where I'd like "subcommands" -- basically something like myprogram command subcommand --flag1 --flag2

Currently the only way around this without doing argument parsing of my own is to actually create myprogram command-subcommand --flag1 --flag2

which I do using builder.addCommand("command-subcommand", ...). I'd like either a dedicated addSubcommand-type API, or to be able to make builder.addCommand("command subcommand", ...) work, which currently doesn't error, but doesn't work, either.

I'm not sure if this is a dumb ask or not; I'd be okay if this was resolved as WONTFIX for ideological/ergonomics reasons. But I'd personally love having this feature added 😉

Asriter commented 3 years ago

I'd like to work on this. But i am so sorry that i could not fully understood what function you want to realize. I add a method named addSubcommand(name, object, parentCommand) to add a subcommand for another command, and the comamnd 'myprogram command subcommand --flag1 --flag2' can run.