Example usage for org.apache.commons.cli Option getArgName

List of usage examples for org.apache.commons.cli Option getArgName

Introduction

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

Prototype

public String getArgName() 

Source Link

Document

Gets the display name for the argument value.

Usage

From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java

private void assertListTasksOption(Options options) {
    Option createOption = options.getOption("l");
    assertEquals("l", createOption.getOpt());
    assertEquals("List all tasks", createOption.getArgName());
    assertEquals("list", createOption.getLongOpt());
    assertEquals("Get all of the tasks in the application", createOption.getDescription());
}

From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java

private void assertDeleteOption(Options options) {
    Option deleteTaskOption = options.getOption("d");
    assertEquals("d", deleteTaskOption.getOpt());
    assertEquals("Delete", deleteTaskOption.getArgName());
    assertEquals("delete", deleteTaskOption.getLongOpt());
    assertEquals("Delete a task by ID", deleteTaskOption.getDescription());
}

From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java

private void assertStandardOption(Options options) {
    Option createOption = options.getOption("s");
    assertEquals("s", createOption.getOpt());
    assertEquals("Accessibility standard", createOption.getArgName());
    assertEquals("standard", createOption.getLongOpt());
    assertEquals(//from   w w  w.j a va  2s . c o  m
            "The accessibility standard to test the URL against. Must be one of Section508, WCAG2A, WCAG2AA, WCAG2AAA",
            createOption.getDescription());
}

From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.spi.TestCliOptionsBuilder.java

@Test
public void testWithArgName() {
    Option option = this.builder.withArgName("argName01").create("test");
    assertNotNull("The option should not be null.", option);
    assertEquals("The arg name is not correct.", "argName01", option.getArgName());
}

From source file:de.hsos.ecs.richwps.wpsmonitor.boundary.cli.command.CommandFormatter.java

private String decorateArg(final Option opt) {
    final StringBuilder strBuilder = new StringBuilder();

    if (opt.hasArg()) {
        if (opt.hasOptionalArg()) {
            strBuilder.append("[");
        }//from w w  w.j ava2s  .c  om

        strBuilder.append("=").append("<").append(opt.getArgName()).append(">");

        if (opt.hasOptionalArg()) {
            strBuilder.append("]");
        }
    }

    return strBuilder.toString();
}

From source file:com.spectralogic.ds3cli.Arguments.java

void addRootArguments() {
    for (final Option optionRoot : rootArgs) {
        optionRoot.setRequired(false);/*from   w w  w. j  a v  a 2s  .c  o m*/
        addOption(optionRoot, optionRoot.getArgName());
    }
}

From source file:de.uni_koblenz.ist.utilities.option_handler.OptionHandler.java

/**
 * Appends the argument name of the given Option to the given StringBuilder.
 * //  w  w  w. j  a v  a  2s.c  om
 * @param out
 *            the StringBuilder to write into.
 * @param current
 *            the Option of which to write the argument name
 */
private void appendArgName(StringBuilder out, Option current) {
    out.append("<").append(current.getArgName()).append(">");
}

From source file:com.emc.ecs.sync.config.ConfigUtilTest.java

private void assertOption(org.apache.commons.cli.Option option, String longOpt, boolean required, int args,
        String argName) {//from  ww w  . j a va 2 s .co  m
    Assert.assertNull(option.getOpt());
    Assert.assertEquals(longOpt, option.getLongOpt());
    Assert.assertEquals(required, option.isRequired());
    Assert.assertEquals(args, option.getArgs());
    Assert.assertEquals(argName, option.getArgName());
}

From source file:kieker.tools.util.CLIHelpFormatter.java

@SuppressWarnings("unchecked")
@Override/*from  ww  w . java  2 s . c  o  m*/
protected StringBuffer renderOptions(final StringBuffer sb, final int width, final Options options,
        final int leftPad, final int descPad) {
    final String lpad = this.createPadding(leftPad);
    final String dpad = this.createPadding(8); // we use a fixed value instead of descPad

    StringBuilder optBuf;

    final List<Option> optList = new ArrayList<Option>(options.getOptions());
    Collections.sort(optList, this.getOptionComparator());

    for (final Iterator<Option> i = optList.iterator(); i.hasNext();) {
        final Option option = i.next();

        optBuf = new StringBuilder(8);

        if (option.getOpt() == null) {
            optBuf.append(lpad).append("   ").append(this.getLongOptPrefix()).append(option.getLongOpt());
        } else {
            optBuf.append(lpad).append(this.getOptPrefix()).append(option.getOpt());

            if (option.hasLongOpt()) {
                optBuf.append(',').append(this.getLongOptPrefix()).append(option.getLongOpt());
            }
        }

        if (option.hasArg()) {
            if (option.hasArgName()) {
                optBuf.append(" <").append(option.getArgName()).append('>');
            } else {
                optBuf.append(' ');
            }
        }

        sb.append(optBuf.toString()).append(this.getNewLine());

        optBuf = new StringBuilder();
        optBuf.append(dpad);

        if (option.getDescription() != null) {
            optBuf.append(option.getDescription());
        }

        this.renderWrappedText(sb, width, dpad.length(), optBuf.toString());

        if (i.hasNext()) {
            sb.append(this.getNewLine());
            sb.append(this.getNewLine());
        }
    }

    return sb;
}

From source file:net.sf.clichart.main.FixedHelpFormatter.java

protected StringBuffer renderOptions(StringBuffer sb, int width, Options options, int leftPad, int descPad) {
    final String lpad = createPadding(leftPad);
    final String dpad = createPadding(descPad);

    //first create list containing only <lpad>-a,--aaa where -a is opt and --aaa is
    //long opt; in parallel look for the longest opt string
    //this list will be then used to sort options ascending
    int max = 0;//from  w  w  w .  j a  va  2s . com
    StringBuffer optBuf;
    List prefixList = new ArrayList();
    Option option;

    //List optList = options.helpOptions();
    Collection optionsCollection = options.getOptions();
    List optList = new ArrayList(optionsCollection);

    Collections.sort(optList, new StringBufferComparator());
    for (Iterator i = optList.iterator(); i.hasNext();) {
        option = (Option) i.next();
        optBuf = new StringBuffer(8);

        if (option.getOpt().equals(" ")) {
            optBuf.append(lpad).append("   " + defaultLongOptPrefix).append(option.getLongOpt());
        } else {
            optBuf.append(lpad).append(defaultOptPrefix).append(option.getOpt());
            if (option.hasLongOpt()) {
                optBuf.append(',').append(defaultLongOptPrefix).append(option.getLongOpt());
            }

        }

        if (option.hasArg()) {
            if (option.hasArgName()) {
                optBuf.append(" <").append(option.getArgName()).append('>');
            } else {
                optBuf.append(' ');
            }
        }

        prefixList.add(optBuf);
        max = optBuf.length() > max ? optBuf.length() : max;
    }
    int x = 0;
    for (Iterator i = optList.iterator(); i.hasNext();) {
        option = (Option) i.next();
        optBuf = new StringBuffer(prefixList.get(x++).toString());

        if (optBuf.length() < max) {
            optBuf.append(createPadding(max - optBuf.length()));
        }
        optBuf.append(dpad);

        int nextLineTabStop = max + descPad;
        renderWrappedText(sb, width, nextLineTabStop, optBuf.append(option.getDescription()).toString());
        if (i.hasNext()) {
            sb.append(defaultNewLine);
        }
    }

    return sb;
}