Search in sources :

Example 91 with CmdLineException

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

the class LoadFundRefData method main.

public static void main(String[] args) {
    LoadFundRefData loadFundRefData = new LoadFundRefData();
    CmdLineParser parser = new CmdLineParser(loadFundRefData);
    try {
        parser.parseArgument(args);
        loadFundRefData.validateArgs(parser);
        loadFundRefData.init();
        loadFundRefData.execute();
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        parser.printUsage(System.err);
    }
    System.exit(0);
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 92 with CmdLineException

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

the class LoadRinggoldData method main.

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

Example 93 with CmdLineException

use of org.kohsuke.args4j.CmdLineException in project gerrit by GerritCodeReview.

the class AbstractProgram method main.

public final int main(final String[] argv) throws Exception {
    final CmdLineParser clp = new CmdLineParser(OptionHandlers.empty(), this);
    try {
        clp.parseArgument(argv);
    } catch (CmdLineException err) {
        if (!clp.wasHelpRequestedByOption()) {
            System.err.println("fatal: " + err.getMessage());
            return 1;
        }
    }
    if (clp.wasHelpRequestedByOption()) {
        StringWriter msg = new StringWriter();
        clp.printDetailedUsage(getName(), msg);
        System.err.println(msg.toString());
        return 1;
    }
    try {
        ProxyUtil.configureHttpProxy();
        return run();
    } catch (Die err) {
        if (showStackTrace) {
            err.printStackTrace();
        } else {
            final Throwable cause = err.getCause();
            final String diemsg = err.getMessage();
            if (cause != null && !cause.getMessage().equals(diemsg)) {
                System.err.println("fatal: " + cause.getMessage().replaceAll("\n", "\nfatal: "));
            }
            System.err.println("fatal: " + diemsg.replaceAll("\n", "\nfatal: "));
        }
        return 128;
    }
}
Also used : Die(com.google.gerrit.common.Die) CmdLineParser(com.google.gerrit.util.cli.CmdLineParser) StringWriter(java.io.StringWriter) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 94 with CmdLineException

use of org.kohsuke.args4j.CmdLineException in project gerrit by GerritCodeReview.

the class AccountGroupUUIDHandler method parseArguments.

@Override
public final int parseArguments(final Parameters params) throws CmdLineException {
    final String n = params.getParameter(0);
    GroupReference group = GroupBackends.findExactSuggestion(groupBackend, n);
    if (group == null) {
        throw new CmdLineException(owner, "Group \"" + n + "\" does not exist");
    }
    setter.addValue(group.getUUID());
    return 1;
}
Also used : GroupReference(com.google.gerrit.common.data.GroupReference) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 95 with CmdLineException

use of org.kohsuke.args4j.CmdLineException in project gerrit by GerritCodeReview.

the class AccountIdHandler method createAccountByLdap.

private Account.Id createAccountByLdap(String user) throws CmdLineException, IOException {
    if (!user.matches(Account.USER_NAME_PATTERN)) {
        throw new CmdLineException(owner, "user \"" + user + "\" not found");
    }
    try {
        AuthRequest req = AuthRequest.forUser(user);
        req.setSkipAuthentication(true);
        return accountManager.authenticate(req).getAccountId();
    } catch (AccountException e) {
        throw new CmdLineException(owner, "user \"" + user + "\" not found");
    }
}
Also used : AuthRequest(com.google.gerrit.server.account.AuthRequest) AccountException(com.google.gerrit.server.account.AccountException) CmdLineException(org.kohsuke.args4j.CmdLineException)

Aggregations

CmdLineException (org.kohsuke.args4j.CmdLineException)105 CmdLineParser (org.kohsuke.args4j.CmdLineParser)80 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