Search in sources :

Example 11 with CmdLineParser

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

the class Main method run.

private static int run(String... args) {
    Args argsObject = new Args();
    CmdLineParser parser = new CmdLineParser(argsObject);
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        e.printStackTrace();
        return 1;
    }
    try {
        return argsObject.run();
    } catch (EdenError | IOException | TException e) {
        e.printStackTrace();
        return 1;
    }
}
Also used : TException(com.facebook.thrift.TException) EdenError(com.facebook.eden.thrift.EdenError) CmdLineParser(org.kohsuke.args4j.CmdLineParser) IOException(java.io.IOException) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 12 with CmdLineParser

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

the class ArtifactConfigTest method shouldMergeCmdLineArgsCorrectly.

@Test
public void shouldMergeCmdLineArgsCorrectly() throws IOException, CmdLineException {
    String jsonString = "{\"repositories\": [{\"url\":\"https://example.com\"}]," + "\"third_party\":\"tp0\"," + "\"repo\":\"br\"," + "\"visibility\":[\"r1\"]," + "\"artifacts\":[\"artifact1\"]}";
    ArtifactConfig base = new ObjectMapper().readValue(jsonString, ArtifactConfig.class);
    ArtifactConfig.CmdLineArgs args = new ArtifactConfig.CmdLineArgs();
    CmdLineParser parser = new CmdLineParser(args);
    parser.parseArgument("-third-party", "tp1", "-maven", "http://bar.co", "artifact2", "-visibility", "r2");
    base.mergeCmdLineArgs(args);
    assertEquals("tp1", base.thirdParty);
    assertEquals(base.artifacts, Lists.newArrayList("artifact1", "artifact2"));
    assertEquals(base.visibility, Lists.newArrayList("r1", "r2"));
    assertEquals("br", base.buckRepoRoot);
    assertEquals("https://example.com", base.repositories.get(0).getUrl());
    assertEquals("http://bar.co", base.repositories.get(1).getUrl());
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 13 with CmdLineParser

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

the class Newts method main.

public static void main(String[] args) throws Exception {
    // NMS-8051: opennms_bootstrap.jar in versions < 18.0.0 does not load
    // all of the system properties, so we need to do this ourselves
    loadOpenNMSProperties();
    Newts cli = new Newts();
    CmdLineParser parser = new CmdLineParser(cli);
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.out.println("Usage: $OPENNMS_HOME/bin/newts <command>");
        System.out.println();
        System.out.println("Supported commands are:");
        System.out.println("\tinit");
        System.out.println();
        System.out.println("Run $OPENNMS_HOME/bin/newts <command> -h for command specific options.");
        return;
    }
    cli.cmd.execute();
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 14 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project ORCID-Source by ORCID.

the class IndexProfiles method main.

public static void main(String[] args) throws IOException {
    IndexProfiles indexProfiles = new IndexProfiles();
    CmdLineParser parser = new CmdLineParser(indexProfiles);
    try {
        parser.parseArgument(args);
        indexProfiles.validateArgs(parser);
        indexProfiles.init();
        indexProfiles.execute();
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        parser.printUsage(System.err);
        System.exit(1);
    } catch (Throwable t) {
        System.err.println(t);
        System.exit(2);
    }
    System.exit(0);
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 15 with CmdLineParser

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

the class Starter method main.

public static void main(String[] args) {
    Starter starter = new Starter();
    CmdLineParser parser = new CmdLineParser(starter, ParserProperties.defaults().withUsageWidth(120));
    try {
        parser.parseArgument(args);
        if (starter.cmd == null) {
            // no command specified, we have to use StarterCommand
            starter.cmd = starter;
        }
        starter.cmd.run(parser);
    } catch (CmdLineException e) {
        starter.LOG.error(e.getMessage());
        starter.LOG.error("");
        starter.cmd.printUsage();
        System.exit(1);
    } catch (CmdRunException ex) {
        handleException(ex, starter.LOG);
        System.exit(2);
    } catch (Exception e) {
        handleException(e, starter.LOG);
        System.exit(3);
    }
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdRunException(org.opennms.features.jmxconfiggenerator.commands.CmdRunException) CmdLineException(org.kohsuke.args4j.CmdLineException) CmdLineException(org.kohsuke.args4j.CmdLineException) CmdRunException(org.opennms.features.jmxconfiggenerator.commands.CmdRunException)

Aggregations

CmdLineParser (org.kohsuke.args4j.CmdLineParser)208 CmdLineException (org.kohsuke.args4j.CmdLineException)165 IOException (java.io.IOException)45 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