Search in sources :

Example 86 with CommandLineParser

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;
}
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 87 with CommandLineParser

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;
}
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 88 with CommandLineParser

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

Example 89 with CommandLineParser

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

Example 90 with CommandLineParser

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

Aggregations

CommandLineParser (org.apache.commons.cli.CommandLineParser)265 CommandLine (org.apache.commons.cli.CommandLine)246 Options (org.apache.commons.cli.Options)206 ParseException (org.apache.commons.cli.ParseException)186 GnuParser (org.apache.commons.cli.GnuParser)158 HelpFormatter (org.apache.commons.cli.HelpFormatter)111 PosixParser (org.apache.commons.cli.PosixParser)61 Option (org.apache.commons.cli.Option)52 IOException (java.io.IOException)48 Path (org.apache.hadoop.fs.Path)42 File (java.io.File)41 DefaultParser (org.apache.commons.cli.DefaultParser)29 Job (org.apache.hadoop.mapreduce.Job)27 Configuration (org.apache.hadoop.conf.Configuration)19 FileInputStream (java.io.FileInputStream)16 Properties (java.util.Properties)15 ArrayList (java.util.ArrayList)14 BasicParser (org.apache.commons.cli.BasicParser)14 FileSystem (org.apache.hadoop.fs.FileSystem)12 URI (java.net.URI)10