private static OptionParser createOptionParser() { OptionParser parser = new OptionParser(); parser.acceptsAll(asList("i", INPUT), "Input VCF file").withRequiredArg().ofType(File.class); parser.acceptsAll(asList("a", ANNOTATOR), "Annotator name").requiredIf("input").withRequiredArg(); parser.acceptsAll(asList("s", SOURCE), "Source file for the annotator").requiredIf("input").withRequiredArg() .ofType(File.class); parser.acceptsAll(asList("o", OUTPUT), "Output VCF file").requiredIf("input").withRequiredArg() .ofType(File.class); parser.acceptsAll(asList("v", VALIDATE), "Use VCF validator on the output file"); parser.acceptsAll(asList("t", VCF_VALIDATOR_LOCATION), "Location of the vcf-validator executable from the vcf-tools suite").withRequiredArg() .ofType(String.class).defaultsTo( System.getProperty(USER_HOME) + File.separator + ".molgenis" + File.separator + "vcf-tools" + File.separator + "bin" + File.separator + "vcf-validator"); parser.acceptsAll(asList("h", HELP), "Prints this help text"); parser.acceptsAll(asList("r", REPLACE), "Enables output file override, replacing a file with the same name as the argument for the -o option"); parser.acceptsAll(asList("u", UPDATE_ANNOTATIONS), "Enables add/updating of annotations, i.e. CADD scores from a different source, by reusing existing annotations when no match was found."); return parser; }
OptionSpec<File> diacriticizerOption = parser.accepts("diacriticizer", "diacriticizer file location (in or out)").withRequiredArg().required() .ofType(File.class); OptionSpec<String> wordsOption = parser.accepts("words", "comma-delimited list of words to test").requiredIf("testDiacriticizer").withRequiredArg() .ofType(String.class).withValuesSeparatedBy(',');
public static void main(String[] args) throws IOException { OptionParser parser = new OptionParser(); parser.accepts(ExtendedCommand.splitConllFile.name(), "split conll file into chunks"); OptionSpec<File> inFileOption = parser.accepts("inFile", "input file").requiredIf(ExtendedCommand.splitConllFile.name()).withRequiredArg() .ofType(File.class); OptionSpec<File> outDirOption = parser.accepts("outDir", "output directory").requiredIf(ExtendedCommand.splitConllFile.name()).withRequiredArg() .ofType(File.class); OptionSpec<String> encodingOption = parser.accepts("encoding", "encoding for input and output").withRequiredArg().ofType(String.class); OptionSpec<Integer> sentencesPerFileOption = parser.accepts("sentencesPerFile", "number of sentences per chunk") .requiredIf(ExtendedCommand.splitConllFile.name()).withRequiredArg().ofType(Integer.class); OptionSpec<Integer> startIndexOption = parser.accepts("startIndex", "the sentence to start on").withRequiredArg().ofType(Integer.class); if (args.length <= 1) { parser.printHelpOn(System.out); return; } OptionSet options = parser.parse(args); File inFile = options.valueOf(inFileOption); File outDir = options.valueOf(outDirOption); String encoding = "UTF-8"; if (options.has(encodingOption)) encoding = options.valueOf(encodingOption); int sentencesPerFile = options.valueOf(sentencesPerFileOption); int startIndex = 1; if (options.has(startIndexOption)) startIndex = options.valueOf(startIndexOption); ConllFileSplitter splitter = new ConllFileSplitter(); splitter.split(inFile, outDir, startIndex, sentencesPerFile, encoding); }
.requiredIf("analyse", "train", "evaluate", "compare", "process").withRequiredArg().ofType(String.class); .requiredIf("train", "process").availableIf("train", "evaluate", "compare", "process").withRequiredArg().ofType(Module.class); OptionSpec<Module> startModuleOption = parser.accepts("startModule", "where to start analysis (or evaluation): " + Arrays.toString(Module.values())) .availableIf("analyse", "evaluate").withRequiredArg().ofType(Module.class);
optionParser.accepts(REQUIRE_CLIENT_CERT, "Make the server require a trusted client certificate to enable a connection"); optionParser.accepts(HTTPS_TRUSTSTORE_PASSWORD, "Password for the trust store").withRequiredArg(); optionParser.accepts(HTTPS_TRUSTSTORE, "Path to an alternative truststore for HTTPS client certificates. Must have a password of \"password\".").requiredIf(REQUIRE_CLIENT_CERT).withRequiredArg(); optionParser.accepts(HTTPS_KEYSTORE_PASSWORD, "Password for the alternative keystore.").withRequiredArg().defaultsTo("password"); optionParser.accepts(HTTPS_KEYSTORE, "Path to an alternative keystore for HTTPS. Password is assumed to be \"password\" if not specified.").requiredIf(HTTPS_TRUSTSTORE).requiredIf(HTTPS_KEYSTORE_PASSWORD).withRequiredArg().defaultsTo(Resources.getResource("keystore").toString()); optionParser.accepts(PROXY_ALL, "Will create a proxy mapping for /* to the specified URL").withRequiredArg(); optionParser.accepts(PRESERVE_HOST_HEADER, "Will transfer the original host header from the client to the proxied service");
.requiredIf(probe, protocol).withRequiredArg(); destinationCertificate = optionParser.accepts("cert", "Receiving AP's certificate (when overriding endpoint)") .requiredIf(destinationUrl).withRequiredArg().ofType(File.class);
.requiredIf(probe, protocol).withRequiredArg(); destinationCertificate = optionParser.accepts("cert", "Receiving AP's certificate (when overriding endpoint)") .requiredIf(destinationUrl).withRequiredArg().ofType(File.class);