Reputation: 43
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;
Upvotes: 0
Views: 101
Reputation: 43
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;
Upvotes: 0