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);
}
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);
}
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;
}
}
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;
}
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");
}
}
Aggregations