Search in sources :

Example 81 with CommandLineParser

use of org.apache.commons.cli.CommandLineParser in project mysql_perf_analyzer by yahoo.

the class App method main.

/* -p --port 9090 
	 * -r --webcontextroot webapps 
	 * -l --logpath logpath 
	 * -w --war webapp war file name
	 */
public static void main(String[] args) throws Exception {
    App myServer = new App();
    CommandLineParser parser = new GnuParser();
    Options options = getAvaliableCommandLineOptions();
    System.out.println(new Date() + " Usage: java -classpath ... com.yahoo.dba.tools.myperfserver.App -j jettyhome " + "-p port -c webcontextroot -k workingDir -l logpath -w war_file");
    readOptionsFromCommandLine(args, parser, options, myServer);
    System.setProperty("logPath", myServer.getLogDirectoryPath());
    PID_FILE = myServer.getWarFile().substring(0, myServer.getWarFile().indexOf('.')) + ".pid";
    checksRunningOfAnotherServerInstance();
    runServer(myServer);
}
Also used : Options(org.apache.commons.cli.Options) GnuParser(org.apache.commons.cli.GnuParser) CommandLineParser(org.apache.commons.cli.CommandLineParser) Date(java.util.Date)

Example 82 with CommandLineParser

use of org.apache.commons.cli.CommandLineParser in project midpoint by Evolveum.

the class AbstractWebServiceClient method parseCommandLine.

private void parseCommandLine(String[] args) throws ParseException {
    CommandLineParser cliParser = new GnuParser();
    commandLine = cliParser.parse(options, args, true);
    if (commandLine.hasOption('h')) {
        printHelp();
        System.exit(0);
    }
    if (commandLine.hasOption('v')) {
        verbose = true;
    }
}
Also used : GnuParser(org.apache.commons.cli.GnuParser) CommandLineParser(org.apache.commons.cli.CommandLineParser)

Example 83 with CommandLineParser

use of org.apache.commons.cli.CommandLineParser in project goci by EBISPOT.

the class ParentMappingApplication 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("mapper", 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("mapper", options, true);
                parseArgs += 2;
            }
        }
    } catch (ParseException e) {
        System.err.println("Failed to read supplied arguments");
        help.printHelp("mapper", 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 84 with CommandLineParser

use of org.apache.commons.cli.CommandLineParser 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 85 with CommandLineParser

use of org.apache.commons.cli.CommandLineParser 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)

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