use of org.kohsuke.args4j.Option in project hudson-2.x by hudson.
the class Launcher method setConnectTo.
@Option(name = "-connectTo", usage = "make a TCP connection to the given host and port, then start communication.", metaVar = "HOST:PORT")
public void setConnectTo(String target) {
String[] tokens = target.split(":");
if (tokens.length != 2) {
System.err.println("Illegal parameter: " + target);
System.exit(1);
}
connectionTarget = new InetSocketAddress(tokens[0], Integer.valueOf(tokens[1]));
}
use of org.kohsuke.args4j.Option in project hudson-2.x by hudson.
the class Launcher method addClasspath.
@Option(name = "-cp", aliases = "-classpath", metaVar = "PATH", usage = "add the given classpath elements to the system classloader.")
public void addClasspath(String pathList) throws Exception {
Method $addURL = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
$addURL.setAccessible(true);
for (String token : pathList.split(File.pathSeparator)) $addURL.invoke(ClassLoader.getSystemClassLoader(), new File(token).toURI().toURL());
// fix up the system.class.path to pretend that those jar files
// are given through CLASSPATH or something.
// some tools like JAX-WS RI and Hadoop relies on this.
System.setProperty("java.class.path", System.getProperty("java.class.path") + File.pathSeparatorChar + pathList);
}
use of org.kohsuke.args4j.Option in project opennms by OpenNMS.
the class Command method printFieldValues.
private void printFieldValues(Class<?> clazz) {
try {
for (Field eachField : clazz.getDeclaredFields()) {
eachField.setAccessible(true);
if (eachField.getAnnotation(Option.class) != null) {
Option option = eachField.getAnnotation(Option.class);
LOG.debug("%tOption {} = {}", option.name(), eachField.get(this));
}
if (eachField.getAnnotation(Argument.class) != null) {
LOG.debug("%tArgument {}", eachField.get(this));
}
}
} catch (IllegalAccessException e) {
Throwables.propagate(e);
}
}
use of org.kohsuke.args4j.Option in project gerrit by GerritCodeReview.
the class ReviewCommand method addLabel.
@Option(name = "--label", aliases = "-l", usage = "custom label(s) to assign", metaVar = "LABEL=VALUE")
void addLabel(final String token) {
LabelVote v = LabelVote.parseWithEquals(token);
// Disallow SUBM.
LabelType.checkName(v.label());
customLabels.put(v.label(), v.value());
}
use of org.kohsuke.args4j.Option in project bnd by bndtools.
the class CommandLineOptions method setRootURL.
@Option(name = "-d", metaVar = "/root/dir", usage = "Root directory " + "(default = the current directory)")
public void setRootURL(File rootURL) throws MalformedURLException, IOException {
if (!rootURL.isDirectory()) {
throw new IOException(rootURL + " is not a directory");
}
this.rootURL = rootURL.toURI().normalize().toURL();
/* make sure the URL ends with a slash */
String rootURLString = this.rootURL.toString();
if (!rootURLString.endsWith("/")) {
this.rootURL = new URL(rootURLString + "/");
}
}
Aggregations