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

addSubcommand without name or alias #611

Closed
andbleo opened this issue Jan 17, 2019 · 4 comments
Closed

addSubcommand without name or alias #611

andbleo opened this issue Jan 17, 2019 · 4 comments

Comments

@andbleo
Copy link

andbleo commented Jan 17, 2019

CommandLine.addSubcommand requires a string name and optionally an array of aliases. Would it be possible to add a version of addSubcommand that just takes in an Object and reads the name and aliases from the @command annotations? If the subcommands annotation can get the name and alias for subcommands, it seems like the programmatic way of adding subcommand should be able to as well.

@remkop
Copy link
Owner

remkop commented Jan 17, 2019

Away from PC now, but this sounds reasonable.

I’m thinking to throw an InitializationException when the specified object doesn’t have a @Command annotation, or is missing the name attribute.

Thoughts?

@andbleo
Copy link
Author

andbleo commented Jan 17, 2019

That makes sense to me.

@remkop remkop added this to the 4.0 milestone Jan 17, 2019
@remkop
Copy link
Owner

remkop commented Apr 2, 2019

I'd love to include this in picocli-4.0, but there are a lot of items on the todo list for that release...

Do you think you will be able to provide a pull request with unit tests?

@remkop remkop modified the milestones: 4.0, 4.0-alpha-3 May 8, 2019
@remkop remkop closed this as completed in 4f61c91 May 8, 2019
@remkop
Copy link
Owner

remkop commented May 8, 2019

This is now available in master. It tries to get the name from the @Command(name = "...") annotation, otherwise from the first @Command(aliases = {"..", "..."}) alias. Should also work for programmatically constructed CommandSpec and CommandLine objects, without an annotated user object.

If no name is found, an InitializationException is thrown.

Can you verify this works as expected?

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

No branches or pull requests

2 participants