Example usage for org.apache.commons.cli Option.Builder hasArg

List of usage examples for org.apache.commons.cli Option.Builder hasArg

Introduction

In this page you can find the example usage for org.apache.commons.cli Option.Builder hasArg.

Prototype

public boolean hasArg() 

Source Link

Document

Query to see if this Option requires an argument

Usage

From source file:de.vandermeer.skb.datatool.applications.options.AO_KeySeparator.java

/**
 * Returns the new option./*  w  w w  .ja v a2 s  . co m*/
 * @param defaultValue option default value
 * @param longDescription option long description
 * @throws NullPointerException - if description parameter is null
 * @throws IllegalArgumentException - if description parameter is empty
 */
public AO_KeySeparator(Character defaultValue, String longDescription) {
    super(defaultValue, "a character as separator between elements of a key", longDescription);

    Option.Builder builder = Option.builder();
    builder.longOpt("key-sep");
    builder.hasArg().argName("SEP");
    builder.required(false);
    this.setCliOption(builder.build());
}

From source file:de.vandermeer.skb.datatool.applications.options.AO_DataTarget.java

/**
 * Returns the new option.//  w w  w.j  av  a2  s  .com
 * @param required true if option is required, false of it is optional
 * @param tlMap entry types supported by an application for long description
 * @throws NullPointerException - if description parameter is null
 * @throws IllegalArgumentException - if description parameter is empty
 */
public AO_DataTarget(boolean required, TypeLoaderMap tlMap) {
    super("specifies a target for output generation and character conversion", "###");

    Option.Builder builder = Option.builder("t");
    builder.longOpt("target");
    builder.hasArg().argName("TARGET");
    builder.required(required);
    this.setCliOption(builder.build());
    this.tlMap = tlMap;
}

From source file:de.vandermeer.skb.datatool.applications.options.AO_DataEntryType.java

/**
 * Returns the new option.//from w w w . j a  v a2 s.c o  m
 * @param tlMap entry types supported by an application for long description
 * @throws NullPointerException - if description parameter is null
 * @throws IllegalArgumentException - if description parameter is empty
 */
public AO_DataEntryType(TypeLoaderMap tlMap) {
    super("specifies the type the tool should process", "###");

    Option.Builder builder = Option.builder("e");
    builder.longOpt("entry-type");
    builder.required(true);
    builder.hasArg().argName("TYPE");
    this.setCliOption(builder.build());

    this.tlMap = tlMap;
}

From source file:gobblin.runtime.cli.PublicMethodsGobblinCliFactory.java

private Options inferOptionsFromMethods() {
    Options options = new Options();

    for (Method method : klazz.getMethods()) {
        if (canUseMethod(method)) {
            EmbeddedGobblinCliOption annotation = method.isAnnotationPresent(EmbeddedGobblinCliOption.class)
                    ? method.getAnnotation(EmbeddedGobblinCliOption.class)
                    : null;/*w  ww. j av a 2  s  .c  o  m*/
            String optionName = annotation == null || Strings.isNullOrEmpty(annotation.name())
                    ? method.getName()
                    : annotation.name();
            String description = annotation == null ? "" : annotation.description();
            Option.Builder builder = Option.builder(optionName).desc(description);
            boolean hasArg = method.getParameterTypes().length > 0;
            if (hasArg) {
                builder.hasArg();
            }
            Option option = builder.build();
            options.addOption(option);
            this.methodsMap.put(option.getOpt(), method);
        }
    }

    return options;
}

From source file:gobblin.runtime.cli.PublicMethodsCliObjectFactory.java

private Options inferOptionsFromMethods() {
    Options options = new Options();

    for (Method method : klazz.getMethods()) {
        if (canUseMethod(method)) {
            CliObjectOption annotation = method.isAnnotationPresent(CliObjectOption.class)
                    ? method.getAnnotation(CliObjectOption.class)
                    : null;/*ww  w .  j  av  a 2s .c om*/
            String optionName = annotation == null || Strings.isNullOrEmpty(annotation.name())
                    ? method.getName()
                    : annotation.name();
            String description = annotation == null ? "" : annotation.description();
            Option.Builder builder = Option.builder(optionName).desc(description);
            boolean hasArg = method.getParameterTypes().length > 0;
            if (hasArg) {
                builder.hasArg();
            }
            Option option = builder.build();
            options.addOption(option);
            this.methodsMap.put(option.getOpt(), method);
        }
    }

    return options;
}