0

I'm trying to create a cli program with Picocli that accepts optional options and params. I want the parameters to be always at the end of the passed arguments, however I do not know how to set that. When I try the following, the options are parsed as filenames too. Is there a way to fix it?

public class WordCount implements Runnable {

@Parameters(index="*", arity = "1..*", description= "The file to count")
public List<String> filenames;

@Option(names = {"-c", "--countBytes"}, description = "Count the number of Bytes in the file")
private Boolean countBytes= false;

@Option(names= {"-w", "countWords"}, description = "Count the number of Words in the file")
private Boolean countWords = false;

@Option(names = {"-l", "--countLines"}, description = "Count the number of lines in the file")
private Boolean countLines =false;

@Option(names = {"-m", "--countCharacters"}, description = "Count the number of characters in the file")
private Boolean countCharacters =false;
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Zainab Lawal
  • 33
  • 1
  • 9

1 Answers1

0

I fixed this by adding the arity attribute to the options. Like:

@Option(names = {"-c", "--countBytes"},arity="1" description = "Count the number of Bytes in the file")
private Boolean countBytes= false;
Zainab Lawal
  • 33
  • 1
  • 9