Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubCommands #472

Open
mkarg opened this issue Jul 3, 2019 · 7 comments
Open

SubCommands #472

mkarg opened this issue Jul 3, 2019 · 7 comments

Comments

@mkarg
Copy link
Collaborator

mkarg commented Jul 3, 2019

Some CLI utilities use multi-word commands alias "Sub Commands": docker container list <options>.

It would be great if JCommander would support the registration of sub commands with unlimited depth.

@mkarg
Copy link
Collaborator Author

mkarg commented Jul 8, 2019

@cbeust Cedric, if you agree about the general benefit of this feature, we would be happy to provide a PR. Can you please deliver your judgement?

@cbeust
Copy link
Owner

cbeust commented Jul 8, 2019

Hi @mkarg,

No objection to the idea, but a bit concerned how big that PR would be. Happy to review it.

@mkarg
Copy link
Collaborator Author

mkarg commented Jul 8, 2019

@cbeust I will assign this task to a new coder we hired. He could start work on that in Q4. As commands are internally JCommander instances, it shouldn't need to much change, as we could call JCommander.addCommand() on that sub-JCommander instances and let them parse the command in turn.

@mkarg
Copy link
Collaborator Author

mkarg commented Jul 9, 2019

@cbeust FYI, today we implemented a PoC for subcommands using unchanged current JCommander, and it worked like a charm. In fact, it works so good that we decided to take the PoC into production. So I think you don't need to worry about the size of the PR. :-)

@cbeust
Copy link
Owner

cbeust commented Jul 9, 2019

That's awesome to hear :)

@david-truong
Copy link

david-truong commented Oct 26, 2019

@mkarg can you share your PoC? We ended up adding a subcommand with a space in it i.e. "container list" and we were shocked but glad it worked. I was wondering if you took a similar approach or had a different implementation.

@mkarg
Copy link
Collaborator Author

mkarg commented Oct 26, 2019

@mkarg can you share your PoC? We ended up adding a subcommand with a space in it i.e. "container list" and we were shocked but glad it worked. I was wondering if you took a similar approach or had a different implementation.

@david-truong https://gist.github.com/mkarg/9d9ca23e6da32b47c7fadaf10ae16ba6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants