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

Method parse signature clash when using from Groovy #135

Closed
pditommaso opened this issue May 28, 2017 · 2 comments
Closed

Method parse signature clash when using from Groovy #135

pditommaso opened this issue May 28, 2017 · 2 comments
Milestone

Comments

@pditommaso
Copy link
Contributor

pditommaso commented May 28, 2017

It turns that when using picocli from groovy the following method signature

public static <T> T parse(T annotatedObject, String... args)

overrides

public List<Object> parse(String... args)

Thus in the following snippet it will try to invoke the static parse method interpreting the first string as the command object instead of a cli argument and resulting in an error.

        CommandLine parser = new CommandLine(new TopCommand())
                .addCommand("make", new MakeCmd())
                .addCommand("docker", new DockerCmd())
                .addCommand("cloud", new CloudCmd())

        List cli = parser.parse('cloud','create')

This makes difficult to use picocli in a groovy based project. Any chance to rename the static parse to a different name eg parseCommand ?

@remkop remkop added this to the 0.9.7 milestone May 28, 2017
@remkop
Copy link
Owner

remkop commented May 28, 2017

Good catch!

I'm thinking to leave the static method as it is, and instead rename the instance method to parseCommands.

The instance method is the one to use when parsing subcommands so it makes sense to me if this method has command in its name.

Also, I realized that the instance method has to change anyway: please see #134 (feedback welcome).

@remkop
Copy link
Owner

remkop commented Jun 4, 2017

Reopening to revisit naming. See #139

@remkop remkop reopened this Jun 4, 2017
@remkop remkop closed this as completed in d1093b0 Jun 4, 2017
remkop added a commit that referenced this issue Jun 4, 2017
…method `CommandLine::parse` to `populateCommand`, and instance method `parseCommands` to `parse`. Closes #135
remkop added a commit that referenced this issue Jun 4, 2017
…method `CommandLine::parse` to `populateCommand`, and instance method `parseCommands` to `parse`.
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