use of org.apache.commons.cli.HelpFormatter in project goci by EBISPOT.
the class AssociationFilterApplication 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("filter", options, true);
parseArgs += 1;
} else {
// find -o option (for asserted output file)
if (cl.hasOption("o")) {
outputFile = new File(cl.getOptionValue("o"));
} else {
System.err.println("-o (output file) argument is required");
help.printHelp("filter", options, true);
parseArgs += 2;
}
if (cl.hasOption("f")) {
inputFile = new File(cl.getOptionValue("f"));
} else {
System.err.println("-f (input file) argument is required");
help.printHelp("filter", options, true);
parseArgs += 2;
}
if (cl.hasOption("p")) {
prune = true;
}
if (cl.hasOption("t")) {
threshold = Double.valueOf(cl.getOptionValue("t"));
}
}
} catch (ParseException e) {
System.err.println("Failed to read supplied arguments");
help.printHelp("filter", options, true);
parseArgs += 4;
}
return parseArgs;
}
use of org.apache.commons.cli.HelpFormatter in project goci by EBISPOT.
the class SnpListBuilderApp 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("publish", options, true);
parseArgs += 1;
} else {
// find -o option (for asserted output file)
if (cl.hasOption("o")) {
outputFilePath = cl.getOptionValue("o");
} 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 += 3;
}
return parseArgs;
}
use of org.apache.commons.cli.HelpFormatter 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.HelpFormatter 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.HelpFormatter in project symmetric-ds by JumpMind.
the class AbstractCommandLauncher method printUsage.
protected void printUsage(Options options) {
PrintWriter writer = new PrintWriter(System.out);
new HelpFormatter().printUsage(writer, 80, app, options);
writer.write("For more options, use " + app + " --" + HELP + "\n");
writer.flush();
}
Aggregations