use of org.apache.commons.cli.CommandLineParser in project goci by EBISPOT.
the class GOCIDataReleaseQCDriver method parseArguments.
private int parseArguments(String[] args) {
CommandLineParser parser = new GnuParser();
HelpFormatter help = new HelpFormatter();
Options options = bindOptions();
int parseArgs = 0;
try {
CommandLine cl = parser.parse(options, args, true);
// check for mode help option
if (cl.hasOption("")) {
// print out mode help
help.printHelp("qc", options, true);
parseArgs += 1;
} else {
// find -o option (for asserted output file)
if (cl.hasOption("a")) {
this.opMode = OperationMode.ALL;
} else if (cl.hasOption("k")) {
this.opMode = OperationMode.KNOWLEDGE_BASE;
} else if (cl.hasOption("e")) {
this.opMode = OperationMode.SUMMARY_EMAIL;
} else if (cl.hasOption("d")) {
this.opMode = OperationMode.DIAGRAM;
} else if (cl.hasOption("s")) {
this.opMode = OperationMode.SOLR_INDEX;
} else {
System.err.println("-o (ontology output file) argument is required");
help.printHelp("publish", options, true);
parseArgs += 2;
}
}
} catch (ParseException e) {
System.err.println("Failed to read supplied arguments");
help.printHelp("publish", options, true);
parseArgs += 4;
}
return parseArgs;
}
use of org.apache.commons.cli.CommandLineParser in project goci by EBISPOT.
the class KBMetricsDriver method parseArguments.
private static int parseArguments(String[] args) {
CommandLineParser parser = new GnuParser();
HelpFormatter help = new HelpFormatter();
Options options = bindOptions();
int parseArgs = 0;
try {
CommandLine cl = parser.parse(options, args, true);
// check for mode help option
if (cl.hasOption("")) {
// print out mode help
help.printHelp("evaluate", options, true);
parseArgs += 1;
} else {
System.out.println("Metrics will be calculated with the following options...");
for (Option opt : cl.getOptions()) {
System.out.println("\t" + opt.getLongOpt() + ": " + opt.getValue() + " (" + opt.getArgName() + ")");
}
if (cl.hasOption("efo")) {
_efoLocation = new URL(cl.getOptionValue("efo"));
System.out.println(_efoLocation);
} else {
System.err.println("-efo (EFO location) argument is required");
help.printHelp("evaluate", options, true);
parseArgs += 2;
}
if (cl.hasOption("gwas")) {
_gwasSchemaLocation = new File(cl.getOptionValue("gwas")).toURI().toURL();
System.out.println(_gwasSchemaLocation);
} else {
System.err.println("-gwas (GWAS Schema File) argument is required");
help.printHelp("evaluate", options, true);
parseArgs += 2;
}
if (cl.hasOption("kb")) {
_kbLocation = new File(cl.getOptionValue("kb")).toURI().toURL();
System.out.println(_kbLocation);
} else {
System.err.println("-kb (Knowledgebase File) argument is required");
help.printHelp("evaluate", options, true);
parseArgs += 2;
}
if (cl.hasOption("w")) {
_watershedCutoff = Integer.parseInt(cl.getOptionValue("w"));
// System.setProperty("watershed.cutoff", String.valueOf(_watershedCutoff));
} else {
System.err.println("-w (Watershed cutoff) argument is required");
help.printHelp("evaluate", options, true);
parseArgs += 2;
}
if (cl.hasOption("out")) {
String outOpt = cl.getOptionValue("out");
_out = new BufferedOutputStream(new FileOutputStream(new File(outOpt)));
} else {
System.out.println("No output file specified, report will be written to standard out");
_out = System.out;
}
}
} catch (ParseException e) {
System.err.println("Failed to read supplied arguments (" + e.getMessage() + ")");
help.printHelp("evaluate", options, true);
parseArgs += 4;
} catch (FileNotFoundException e) {
System.err.println("Failed to read supplied arguments - file not found (" + e.getMessage() + ")");
help.printHelp("evaluate", options, true);
parseArgs += 5;
} catch (MalformedURLException e) {
System.err.println("Failed to read supplied arguments - a supplied argument was not a valid URL " + "(" + e.getMessage() + ")");
help.printHelp("evaluate", options, true);
parseArgs += 6;
}
return parseArgs;
}
use of org.apache.commons.cli.CommandLineParser in project GNS by MobilityFirst.
the class ThroughputAsynchMultiClientTest method initializeOptions.
private static CommandLine initializeOptions(String[] args) throws ParseException {
Option helpOption = new Option("help", "Prints Usage");
Option aliasOption = OptionBuilder.withArgName("alias").hasArg().withDescription("the alias (HRN) to use").create("alias");
Option operationOption = OptionBuilder.withArgName("op").hasArg().withDescription("the operation to perform (read or update - default is read)").create("op");
Option rateOption = OptionBuilder.withArgName("rate").hasArg().withDescription("the rate in ops per second").create("rate");
Option incOption = OptionBuilder.withArgName("inc").hasArg().withDescription("the increment used with rate").create("inc");
Option clientsOption = OptionBuilder.withArgName("clients").hasArg().withDescription("number of clients used to send (default 10)").create("clients");
Option requestsPerClientOption = OptionBuilder.withArgName("requests").hasArg().withDescription("number of requests sent by each client each time").create("requests");
Option guidsPerRequestOption = OptionBuilder.withArgName("guids").hasArg().withDescription("number of guids for each request").create("guids");
Option useExistingGuidsOption = new Option("useExistingGuids", "use guids in account Guid instead of creating new ones");
Option updateAliasOption = new Option("updateAlias", true, "Alias of guid to update/read");
Option updateFieldOption = new Option("updateField", true, "Field to read/update");
Option updateValueOption = new Option("updateValue", true, "Value to use in read/update");
commandLineOptions = new Options();
commandLineOptions.addOption(aliasOption);
commandLineOptions.addOption(operationOption);
commandLineOptions.addOption(rateOption);
commandLineOptions.addOption(incOption);
commandLineOptions.addOption(clientsOption);
commandLineOptions.addOption(requestsPerClientOption);
commandLineOptions.addOption(guidsPerRequestOption);
commandLineOptions.addOption(helpOption);
commandLineOptions.addOption(updateAliasOption);
commandLineOptions.addOption(updateFieldOption);
commandLineOptions.addOption(updateValueOption);
commandLineOptions.addOption(useExistingGuidsOption);
CommandLineParser parser = new GnuParser();
return parser.parse(commandLineOptions, args);
}
use of org.apache.commons.cli.CommandLineParser in project GNS by MobilityFirst.
the class ReplicaLatencyTest method initializeOptions.
private static CommandLine initializeOptions(String[] args) throws ParseException {
Option help = new Option("help", "Prints Usage");
Option alias = OptionBuilder.withArgName("alias").hasArg().withDescription("the alias (HRN) to use for the account").create("alias");
Option host = OptionBuilder.withArgName("host").hasArg().withDescription("the GNS host").create("host");
Option port = OptionBuilder.withArgName("port").hasArg().withDescription("the GNS port").create("port");
Option debug = new Option("debug", "show output");
Option closeActiveReplica = OptionBuilder.withArgName("closeAR").hasArg().withDescription("the active replica close to you").create("closeAR");
commandLineOptions = new Options();
commandLineOptions.addOption(alias);
commandLineOptions.addOption(host);
commandLineOptions.addOption(port);
commandLineOptions.addOption(debug);
commandLineOptions.addOption(closeActiveReplica);
commandLineOptions.addOption(help);
CommandLineParser parser = new GnuParser();
return parser.parse(commandLineOptions, args);
}
use of org.apache.commons.cli.CommandLineParser in project GNS by MobilityFirst.
the class CommandLineInterface method initializeOptions.
private static CommandLine initializeOptions(String[] args) throws ParseException {
Option help = new Option("help", "Prints Usage");
Option silent = new Option("silent", "Disables output");
Option noDefaults = new Option("noDefaults", "Don't use server and guid defaults");
commandLineOptions = new Options();
commandLineOptions.addOption(help);
commandLineOptions.addOption(silent);
commandLineOptions.addOption(noDefaults);
CommandLineParser parser = new GnuParser();
return parser.parse(commandLineOptions, args, false);
}
Aggregations