Search in sources :

Example 21 with CmdLineException

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

the class SendBadOrgsEmail method main.

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

Example 22 with CmdLineException

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

the class UpdateSalesForceMember method main.

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

Example 23 with CmdLineException

use of org.kohsuke.args4j.CmdLineException 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)

Example 24 with CmdLineException

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

the class CLIPinger method doMain.

public void doMain(String[] args) throws CmdLineException {
    setPropertiesIfPossible();
    CmdLineParser parser = new CmdLineParser(this);
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        parser.printUsage(System.err);
        System.exit(1);
    }
    InetAddress host;
    double rttMs;
    if (s_arguments.isEmpty()) {
        parser.printUsage(System.err);
        System.exit(1);
    }
    try {
        host = InetAddress.getByName(s_arguments.get(0));
        final PingerFactory pf = new BestMatchPingerFactory();
        final Pinger p = pf.getInstance(Integer.decode(s_dscp), s_allowFragmentation);
        for (int i = 0; i < s_count; i++) {
            Number rtt = p.ping(host, s_timeout, s_retries);
            if (rtt == null) {
                System.out.println("request timed out");
            } else {
                rttMs = rtt.doubleValue() / 1000.0;
                System.out.println("Reply from " + host.getHostName() + " (" + host.getHostAddress() + "): time=" + rttMs + " ms");
            }
            if (i < s_count - 1) {
                Thread.sleep(s_interval);
            }
        }
    } catch (UnknownHostException ex) {
        System.out.println("Unknown host " + args[0]);
        System.exit(1);
    } catch (Throwable ex) {
        System.out.println("Unexpected exception while pinging " + args[0] + ": " + ex.getMessage());
        ex.printStackTrace();
        System.exit(1);
    } finally {
        System.exit(0);
    }
}
Also used : Pinger(org.opennms.netmgt.icmp.Pinger) PingerFactory(org.opennms.netmgt.icmp.PingerFactory) BestMatchPingerFactory(org.opennms.netmgt.icmp.best.BestMatchPingerFactory) CmdLineParser(org.kohsuke.args4j.CmdLineParser) BestMatchPingerFactory(org.opennms.netmgt.icmp.best.BestMatchPingerFactory) UnknownHostException(java.net.UnknownHostException) InetAddress(java.net.InetAddress) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 25 with CmdLineException

use of org.kohsuke.args4j.CmdLineException 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)

Aggregations

CmdLineException (org.kohsuke.args4j.CmdLineException)100 CmdLineParser (org.kohsuke.args4j.CmdLineParser)75 IOException (java.io.IOException)16 File (java.io.File)14 ArrayList (java.util.ArrayList)11 PrintStream (java.io.PrintStream)7 StringWriter (java.io.StringWriter)6 List (java.util.List)5 FileOutputStream (java.io.FileOutputStream)4 Path (java.nio.file.Path)4 CmdLineParser (com.google.gerrit.util.cli.CmdLineParser)3 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 Project (com.google.gerrit.reviewdb.client.Project)2 OrmException (com.google.gwtorm.server.OrmException)2 Hudson (hudson.model.Hudson)2