Search in sources :

Example 1 with Option

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]));
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Option(org.kohsuke.args4j.Option)

Example 2 with Option

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);
}
Also used : Method(java.lang.reflect.Method) File(java.io.File) Option(org.kohsuke.args4j.Option)

Example 3 with Option

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);
    }
}
Also used : Field(java.lang.reflect.Field) Argument(org.kohsuke.args4j.Argument) Option(org.kohsuke.args4j.Option)

Example 4 with Option

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());
}
Also used : LabelVote(com.google.gerrit.server.util.LabelVote) Option(org.kohsuke.args4j.Option)

Example 5 with Option

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 + "/");
    }
}
Also used : IOException(java.io.IOException) URL(java.net.URL) Option(org.kohsuke.args4j.Option)

Aggregations

Option (org.kohsuke.args4j.Option)11 Field (java.lang.reflect.Field)4 File (java.io.File)2 IOException (java.io.IOException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 LabelVote (com.google.gerrit.server.util.LabelVote)1 Serializable (java.io.Serializable)1 Method (java.lang.reflect.Method)1 InetSocketAddress (java.net.InetSocketAddress)1 SecureRandom (java.security.SecureRandom)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1