如何使用Picocli传递参数而不指定其索引



我正在尝试创建一个Picocli程序,接受可选选项和参数。我希望参数总是在传递参数的末尾,但是我不知道如何设置。当我尝试以下操作时,这些选项也被解析为文件名。有办法解决吗?

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;

我通过向选项添加arity属性来解决这个问题。如:

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

最新更新