Search in sources :

Example 1 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project buck by facebook.

the class ArtifactConfig method fromCommandLineArgs.

public static ArtifactConfig fromCommandLineArgs(String[] args) throws CmdLineException, IOException {
    CmdLineArgs parsedArgs = new CmdLineArgs();
    CmdLineParser parser = new CmdLineParser(parsedArgs);
    parser.parseArgument(args);
    if (parsedArgs.showHelp) {
        usage(parser);
    }
    ArtifactConfig artifactConfig;
    // If the -config argument was specified, load a config from JSON.
    if (parsedArgs.artifactConfigJson != null) {
        ObjectMapper mapper = new ObjectMapper();
        File jsonFile = new File(parsedArgs.artifactConfigJson);
        artifactConfig = mapper.readValue(jsonFile, ArtifactConfig.class);
    } else {
        artifactConfig = new ArtifactConfig();
    }
    if (artifactConfig.buckRepoRoot == null && parsedArgs.buckRepoRoot == null) {
        usage(parser);
    }
    artifactConfig.mergeCmdLineArgs(parsedArgs);
    return artifactConfig;
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with CmdLineParser

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

the class RawIndexBenchmark method main.

/**
   * Main method for the class. Parses the command line arguments, and invokes the benchmark.
   *
   * @param args Command line arguments.
   * @throws Exception
   */
public static void main(String[] args) throws Exception {
    RawIndexBenchmark benchmark = new RawIndexBenchmark();
    CmdLineParser parser = new CmdLineParser(benchmark);
    parser.parseArgument(args);
    benchmark.run();
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser)

Example 3 with CmdLineParser

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

the class PinotAdministrator method execute.

public void execute(String[] args) throws Exception {
    try {
        CmdLineParser parser = new CmdLineParser(this);
        parser.parseArgument(args);
        if ((_subCommand == null) || _help) {
            printUsage();
        } else if (_subCommand.getHelp()) {
            _subCommand.printUsage();
            _status = true;
        } else {
            _status = _subCommand.execute();
        }
    } catch (CmdLineException e) {
        LOGGER.error("Error: {}", e.getMessage());
    } catch (Exception e) {
        LOGGER.error("Exception caught: ", e);
    }
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 4 with CmdLineParser

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

the class PinotToolLauncher method execute.

public void execute(String[] args) throws Exception {
    try {
        CmdLineParser parser = new CmdLineParser(this);
        parser.parseArgument(args);
        if ((_subCommand == null) || _help) {
            printUsage();
        } else if (_subCommand.getHelp()) {
            _subCommand.printUsage();
        } else {
            _subCommand.execute();
        }
    } catch (CmdLineException e) {
        LOGGER.error("Error: {}", e.getMessage());
    } catch (Exception e) {
        LOGGER.error("Exception caught: ", e);
    }
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 5 with CmdLineParser

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

the class MoveReplicaGroup method main.

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

Aggregations

CmdLineParser (org.kohsuke.args4j.CmdLineParser)202 CmdLineException (org.kohsuke.args4j.CmdLineException)159 IOException (java.io.IOException)42 File (java.io.File)27 Test (org.junit.Test)14 KeeperException (org.apache.zookeeper.KeeperException)12 ArrayList (java.util.ArrayList)11 HyracksConnection (org.apache.hyracks.api.client.HyracksConnection)10 IHyracksClientConnection (org.apache.hyracks.api.client.IHyracksClientConnection)10 Directory (org.apache.lucene.store.Directory)10 FSDirectory (org.apache.lucene.store.FSDirectory)10 JobId (org.apache.hyracks.api.job.JobId)9 JobSpecification (org.apache.hyracks.api.job.JobSpecification)9 ClientException (com.ms.silverking.cloud.dht.client.ClientException)8 PutException (com.ms.silverking.cloud.dht.client.PutException)8 SKGridConfiguration (com.ms.silverking.cloud.dht.gridconfig.SKGridConfiguration)8 PrintStream (java.io.PrintStream)8 List (java.util.List)8 RetrievalException (com.ms.silverking.cloud.dht.client.RetrievalException)7 IndexArgs (io.anserini.index.IndexArgs)7