Search in sources :

Example 91 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project pinot by linkedin.

the class VerifySegmentState method main.

public static void main(String[] args) throws Exception {
    VerifySegmentState verifier = new VerifySegmentState();
    CmdLineParser cmdLineParser = new CmdLineParser(verifier);
    try {
        cmdLineParser.parseArgument(args);
    } catch (CmdLineException e) {
        LOGGER.error("Failed to read command line arguments: ", e);
        cmdLineParser.printUsage(System.err);
        System.exit(1);
    }
    verifier.execute();
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 92 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project pinot by linkedin.

the class QueryRunner method main.

public static void main(String[] args) throws Exception {
    QueryRunner queryRunner = new QueryRunner();
    CmdLineParser parser = new CmdLineParser(queryRunner);
    parser.parseArgument(args);
    if (queryRunner._help) {
        queryRunner.printUsage();
    } else {
        queryRunner.execute();
    }
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser)

Example 93 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project gitblit by gitblit.

the class GitBlitServer4UITests method main.

public static void main(String... args) {
    GitBlitServer4UITests server = new GitBlitServer4UITests();
    // filter out the baseFolder parameter
    List<String> filtered = new ArrayList<String>();
    String folder = "data";
    for (int i = 0; i < args.length; i++) {
        String arg = args[i];
        if (arg.equals("--baseFolder")) {
            if (i + 1 == args.length) {
                System.out.println("Invalid --baseFolder parameter!");
                System.exit(-1);
            } else if (args[i + 1] != ".") {
                folder = args[i + 1];
            }
            i = i + 1;
        } else {
            filtered.add(arg);
        }
    }
    Params.baseFolder = folder;
    Params params = new Params();
    CmdLineParser parser = new CmdLineParser(params);
    try {
        parser.parseArgument(filtered);
        if (params.help) {
            server.usage(parser, null);
        }
    } catch (CmdLineException t) {
        server.usage(parser, t);
    }
    if (params.stop) {
        server.stop(params);
    } else {
        server.start(params);
    }
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) ArrayList(java.util.ArrayList) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 94 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project es6draft by anba.

the class Repl method parseOptions.

private static void parseOptions(Options options, String[] args) {
    ParserProperties properties = ParserProperties.defaults().withUsageWidth(128);
    CmdLineParser parser = new CmdLineParser(options, properties);
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        System.err.println(getUsageString(parser, false));
        System.exit(1);
    }
    if (options.showVersion) {
        System.out.println(getVersionString());
        System.exit(0);
    }
    if (options.showHelp) {
        System.out.println(getUsageString(parser, false));
        System.exit(0);
    }
    if (options.showExtendedHelp) {
        System.out.println(getUsageString(parser, true));
        System.exit(0);
    }
    if (options.debug || options.fullDebug || options.debugInfo) {
        // Disable interpreter when bytecode is requested
        options.noInterpreter = true;
    }
    if (options.fileName != null) {
        // Execute as last script
        if (options.fileName.toString().equals("-")) {
            // "-" is a short-hand to request reading from System.in
            if (System.console() == null) {
                // System.in is not interactive
                options.evalScripts.add(new EvalString(read(System.in)));
            } else {
                options.interactive = true;
            }
        } else {
            options.evalScripts.add(new EvalPath(options.fileName));
        }
    }
    if (options.evalScripts.isEmpty()) {
        // Default to interactive mode when no files or expressions were set
        options.interactive = true;
        // Warn if --module is used without input files.
        if (options.module) {
            System.err.println(formatMessage("module_no_files"));
        }
    }
    if (options.ecmascript7) {
        System.err.println(formatMessage("deprecated.es7"));
    }
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) ParserProperties(org.kohsuke.args4j.ParserProperties) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 95 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project newts by OpenNMS.

the class MergeSort method createCmdLineParser.

private CmdLineParser createCmdLineParser() {
    return new CmdLineParser(this) {

        @SuppressWarnings("rawtypes")
        @Override
        public void addArgument(final Setter setter, Argument a) {
            Setter newSetter = setter;
            if (setter instanceof MethodSetter) {
                newSetter = new Setter() {

                    @SuppressWarnings("unchecked")
                    @Override
                    public void addValue(Object value) throws CmdLineException {
                        setter.addValue(value);
                    }

                    @Override
                    public Class getType() {
                        return setter.getType();
                    }

                    @Override
                    public boolean isMultiValued() {
                        return false;
                    }

                    @Override
                    public FieldSetter asFieldSetter() {
                        return setter.asFieldSetter();
                    }

                    @Override
                    public AnnotatedElement asAnnotatedElement() {
                        return setter.asAnnotatedElement();
                    }
                };
            }
            super.addArgument(newSetter, a);
        }
    };
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) Argument(org.kohsuke.args4j.Argument) MethodSetter(org.kohsuke.args4j.spi.MethodSetter) FieldSetter(org.kohsuke.args4j.spi.FieldSetter) MethodSetter(org.kohsuke.args4j.spi.MethodSetter) Setter(org.kohsuke.args4j.spi.Setter) FieldSetter(org.kohsuke.args4j.spi.FieldSetter) AnnotatedElement(java.lang.reflect.AnnotatedElement) CmdLineException(org.kohsuke.args4j.CmdLineException)

Aggregations

CmdLineParser (org.kohsuke.args4j.CmdLineParser)119 CmdLineException (org.kohsuke.args4j.CmdLineException)80 File (java.io.File)16 Test (org.junit.Test)14 IOException (java.io.IOException)11 HyracksConnection (org.apache.hyracks.api.client.HyracksConnection)10 IHyracksClientConnection (org.apache.hyracks.api.client.IHyracksClientConnection)10 ArrayList (java.util.ArrayList)9 JobId (org.apache.hyracks.api.job.JobId)9 JobSpecification (org.apache.hyracks.api.job.JobSpecification)9 PrintStream (java.io.PrintStream)6 FileOutputStream (java.io.FileOutputStream)4 List (java.util.List)4 FeatureExtractors (io.anserini.ltr.feature.FeatureExtractors)3 Qrels (io.anserini.util.Qrels)3 Directory (org.apache.lucene.store.Directory)3 FSDirectory (org.apache.lucene.store.FSDirectory)3 ConsoleReporter (com.codahale.metrics.ConsoleReporter)2 MetricRegistry (com.codahale.metrics.MetricRegistry)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2