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

Parser bug: first argument following clustered options is treated as a positional parameter #233

Closed
mgrossmann opened this issue Nov 9, 2017 · 6 comments
Milestone

Comments

@mgrossmann
Copy link

mgrossmann commented Nov 9, 2017

I use two boolean options. e.g. -c (compress) -e (encrypt) and one string option e.g. -o (outputFile) .
The i use parameter "1..*" FILE for inputFileNames(String[]).

Usage:
cmd -c -e -o OUTPUTFILE INPUTFILE1 INPUTFILE2 INPUTFILE3 -> work
cmd -ceo OUTPUTFILE INPUTFILE1 INPUTFILE2 INPUTFILE3 -> work
cmd -ce -o OUTPUTFILE INPUTFILE1 INPUTFILE2 INPUTFILE -> failed
will be parsed to:
outputFIle=null
inputFileNames[0]="-o"
inputFileNames[1]="OUTPUTFILE"
inputFileNames[2]="INPUTFILE1"
...
cmd -ce -o=OUTPUTFILE INPUTFILE1 INPUTFILE2 INPUTFILE -> failed
will be parsed to:
outputFIle=null
inputFileNames[0]="-o=OUTPUTFILE"
inputFileNames[1]="INPUTFILE1"
...

@mgrossmann mgrossmann changed the title Problems mixing opti Problems mixing options and parameters Nov 9, 2017
@remkop
Copy link
Owner

remkop commented Nov 9, 2017

I will look at this when I get to a PC. Does this match your class? Please let me know if you use different field types or annotation attributes (other than description).

class Mix {
  @Option(names = “-e”, description = “Encrypt”)
  boolean encrypt;

  @Option(names = “-c”, description = “Compress”)
  boolean compress;

  @Option(names = “-o”, description = “Output file”)
  String outputFile;

  @Parameters(arity = “1..*”, description = “One or more input files”)
  String[] inputFiles;
}

@remkop
Copy link
Owner

remkop commented Nov 10, 2017

I was able to reproduce the issue. Thanks for reporting this!

@remkop remkop changed the title Problems mixing options and parameters Parser bug: first argument following clustered options is treated as a positional parameter Nov 10, 2017
@remkop remkop added this to the 2.0.3 milestone Nov 10, 2017
@remkop
Copy link
Owner

remkop commented Nov 10, 2017

I will try to release picocli 2.0.3 with the fix this weekend.

remkop added a commit that referenced this issue Nov 10, 2017
… is treated as a positional parameter. Thanks to [mgrossmann](https://github.com/mgrossmann).

Closes #233
@remkop remkop closed this as completed in d808111 Nov 10, 2017
@remkop
Copy link
Owner

remkop commented Nov 11, 2017

Picocli 2.0.3 has been released with this fix.

@remkop
Copy link
Owner

remkop commented Nov 11, 2017

Thanks again for the bug report! Keep ‘em coming!

@mgrossmann
Copy link
Author

Thanks for your amazing work on this project!

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