CmdOption 是一个简单的注解驱动的命令行参数解析工具包,你所需要做的就是简单配置对象,每个字段和方法通过注解来定义。
示例代码:
public class Config { @CmdOption(names = {"--verbose", "-v"}, description = "Be more verbose") private boolean verbose; @CmdOption(names = {"--options", "-o"}, args = {"name", "value"}, maxCount = -1, description = "Additional options when processing names") private final Map options = new LinkedHashMap(); @CmdOption(args = {"file"}, description = "Names to process", minCount = 1, maxCount = -1) private final Listnames = new LinkedList(); }