Example usage for org.apache.commons.cli2.builder ArgumentBuilder withSubsequentSeparator

List of usage examples for org.apache.commons.cli2.builder ArgumentBuilder withSubsequentSeparator

Introduction

In this page you can find the example usage for org.apache.commons.cli2.builder ArgumentBuilder withSubsequentSeparator.

Prototype

public final ArgumentBuilder withSubsequentSeparator(final char newSubsequentSeparator) 

Source Link

Document

Sets the character used to separate the values from each other.

Usage

From source file:it.jnrpe.server.console.PluginCommand.java

private Option toOption(PluginOption po) {
    DefaultOptionBuilder oBuilder = new DefaultOptionBuilder();

    oBuilder.withShortName(po.getOption()).withDescription(po.getDescription())
            .withRequired("true".equalsIgnoreCase(po.getRequired()));

    if (po.getLongOpt() != null) {
        oBuilder.withLongName(po.getLongOpt());
    }//  w w  w  . j a  v  a  2s.  c  om

    if (po.hasArgs()) {
        ArgumentBuilder aBuilder = new ArgumentBuilder();

        if (po.getArgName() != null) {
            aBuilder.withName(po.getArgName());
        }

        if (po.getArgsOptional()) {
            aBuilder.withMinimum(0);
        }

        if (po.getArgsCount() != null) {
            aBuilder.withMaximum(po.getArgsCount());
        } else {
            aBuilder.withMaximum(1);
        }

        if (po.getValueSeparator() != null && po.getValueSeparator().length() != 0) {
            aBuilder.withInitialSeparator(po.getValueSeparator().charAt(0));
            aBuilder.withSubsequentSeparator(po.getValueSeparator().charAt(0));
        }
        oBuilder.withArgument(aBuilder.create());
    }

    return oBuilder.create();
}

From source file:it.jnrpe.plugins.PluginOption.java

/**
 * Convert this {@link PluginOption} to the Option required by Apache.
 * Commons Cli.//from w w w.j  a  va2 s.  c o m
 *
        
 * @return The option object required by commons cli */
public Option toOption() {
    DefaultOptionBuilder oBuilder = new DefaultOptionBuilder();

    oBuilder.withShortName(option).withDescription(description).withRequired(required);

    if (longOptionName != null) {
        oBuilder.withLongName(longOptionName);
    }

    if (hasArgs) {
        ArgumentBuilder aBuilder = new ArgumentBuilder();

        if (argName != null) {
            aBuilder.withName(argName);
        }

        if (argsAreOptional) {
            aBuilder.withMinimum(0);
        }

        if (argsCount != null) {
            aBuilder.withMaximum(argsCount);
        } else {
            aBuilder.withMaximum(1);
        }

        if (argsValueSeparator != null && argsValueSeparator.length() != 0) {
            aBuilder.withInitialSeparator(argsValueSeparator.charAt(0));
            aBuilder.withSubsequentSeparator(argsValueSeparator.charAt(0));
        }
        oBuilder.withArgument(aBuilder.create());
    }

    return oBuilder.create();
}