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