Search in sources :

Example 76 with HelpFormatter

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;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) GnuParser(org.apache.commons.cli.GnuParser) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) File(java.io.File)

Example 77 with HelpFormatter

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;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) GnuParser(org.apache.commons.cli.GnuParser) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException)

Example 78 with HelpFormatter

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;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) GnuParser(org.apache.commons.cli.GnuParser) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException)

Example 79 with HelpFormatter

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;
}
Also used : Options(org.apache.commons.cli.Options) MalformedURLException(java.net.MalformedURLException) GnuParser(org.apache.commons.cli.GnuParser) FileNotFoundException(java.io.FileNotFoundException) URL(java.net.URL) HelpFormatter(org.apache.commons.cli.HelpFormatter) CommandLine(org.apache.commons.cli.CommandLine) FileOutputStream(java.io.FileOutputStream) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 80 with HelpFormatter

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();
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) PrintWriter(java.io.PrintWriter)

Aggregations

HelpFormatter (org.apache.commons.cli.HelpFormatter)273 Options (org.apache.commons.cli.Options)136 CommandLine (org.apache.commons.cli.CommandLine)126 CommandLineParser (org.apache.commons.cli.CommandLineParser)110 ParseException (org.apache.commons.cli.ParseException)103 GnuParser (org.apache.commons.cli.GnuParser)92 Path (org.apache.hadoop.fs.Path)42 PrintWriter (java.io.PrintWriter)35 Option (org.apache.commons.cli.Option)29 Job (org.apache.hadoop.mapreduce.Job)27 Configuration (org.apache.hadoop.conf.Configuration)21 File (java.io.File)17 IOException (java.io.IOException)14 DefaultParser (org.apache.commons.cli.DefaultParser)13 PosixParser (org.apache.commons.cli.PosixParser)12 FileSystem (org.apache.hadoop.fs.FileSystem)12 BasicParser (org.apache.commons.cli.BasicParser)11 ArrayList (java.util.ArrayList)8 URI (java.net.URI)6 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)6