Search in sources :

Example 16 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser 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 17 with CmdLineParser

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

the class MigrateNamesAndBioToTheirOwnTables method init.

@SuppressWarnings("resource")
private void init(String[] args) throws CmdLineException {
    CmdLineParser parser = new CmdLineParser(this);
    parser.parseArgument(args);
    if (batchSize == 0) {
        batchSize = 10000;
    }
    if (numberOfBatches == 0) {
        numberOfBatches = -1;
    }
    ApplicationContext context = new ClassPathXmlApplicationContext("orcid-persistence-context.xml");
    profileDao = (ProfileDao) context.getBean("profileDao");
    recordNameDao = (RecordNameDao) context.getBean("recordNameDao");
    biographyDao = (BiographyDao) context.getBean("biographyDao");
    transactionTemplate = (TransactionTemplate) context.getBean("transactionTemplate");
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) CmdLineParser(org.kohsuke.args4j.CmdLineParser) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Example 18 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser 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 19 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser 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 20 with CmdLineParser

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

the class AddScopesToExistingClients method main.

public static void main(String[] args) {
    AddScopesToExistingClients addScopesToExistingClients = new AddScopesToExistingClients();
    CmdLineParser parser = new CmdLineParser(addScopesToExistingClients);
    try {
        parser.parseArgument(args);
        addScopesToExistingClients.validateParameters(parser);
        addScopesToExistingClients.init();
        addScopesToExistingClients.process();
        System.out.println();
        System.out.println();
        System.out.println(addScopesToExistingClients.getClientsUpdated() + " clients were updated");
        System.out.println();
        System.out.println();
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        parser.printUsage(System.err);
        System.exit(1);
    }
    System.exit(0);
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException)

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