Example usage for org.apache.commons.cli2.util HelpFormatter getPageWidth

List of usage examples for org.apache.commons.cli2.util HelpFormatter getPageWidth

Introduction

In this page you can find the example usage for org.apache.commons.cli2.util HelpFormatter getPageWidth.

Prototype

public int getPageWidth() 

Source Link

Usage

From source file:it.jnrpe.client.JNRPEClient.java

/**
 * Prints usage instrunctions and, eventually, an error message about the
 * latest execution./*w  w w.  j a  va2 s .co  m*/
 * 
 * @param e
 *            The exception error
 */
@SuppressWarnings("unchecked")
private static void printUsage(final Exception e) {
    printVersion();

    StringBuilder sbDivider = new StringBuilder("=");

    if (e != null) {
        System.out.println(e.getMessage() + "\n");
    }

    HelpFormatter hf = new HelpFormatter();
    while (sbDivider.length() < hf.getPageWidth()) {
        sbDivider.append('=');
    }

    // DISPLAY SETTING
    Set displaySettings = hf.getDisplaySettings();

    displaySettings.clear();
    displaySettings.add(DisplaySetting.DISPLAY_GROUP_EXPANDED);
    displaySettings.add(DisplaySetting.DISPLAY_PARENT_CHILDREN);

    // USAGE SETTING
    Set usageSettings = hf.getFullUsageSettings();
    usageSettings.clear();
    usageSettings.add(DisplaySetting.DISPLAY_PARENT_ARGUMENT);
    usageSettings.add(DisplaySetting.DISPLAY_ARGUMENT_BRACKETED);
    usageSettings.add(DisplaySetting.DISPLAY_PARENT_CHILDREN);
    usageSettings.add(DisplaySetting.DISPLAY_GROUP_EXPANDED);

    hf.setDivider(sbDivider.toString());

    hf.setGroup(configureCommandLine());
    hf.print();
}

From source file:it.jnrpe.server.JNRPEServer.java

/**
 * Prints the JNRPE Server usage and, eventually, the error about the last
 * invocation.//from   www .  j a v  a 2 s  .com
 * 
 * @param e
 *            The last error. Can be null.
 */
@SuppressWarnings("unchecked")
private static void printUsage(final Exception e) {
    printVersion();
    if (e != null) {
        System.out.println(e.getMessage() + "\n");
    }

    HelpFormatter hf = new HelpFormatter();

    StringBuilder sbDivider = new StringBuilder("=");
    while (sbDivider.length() < hf.getPageWidth()) {
        sbDivider.append("=");
    }

    // DISPLAY SETTING
    hf.getDisplaySettings().clear();
    hf.getDisplaySettings().add(DisplaySetting.DISPLAY_GROUP_EXPANDED);
    hf.getDisplaySettings().add(DisplaySetting.DISPLAY_PARENT_CHILDREN);

    // USAGE SETTING

    hf.getFullUsageSettings().clear();
    hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_PARENT_ARGUMENT);
    hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_ARGUMENT_BRACKETED);
    hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_PARENT_CHILDREN);
    hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_GROUP_EXPANDED);

    hf.setDivider(sbDivider.toString());

    hf.setGroup(configureCommandLine());
    hf.print();
    System.exit(0);
}

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

/**
 * Prints the help related to the plugin to a specified output.
 * /*w w  w  . j a v a  2 s.  co m*/
 * @param out
 *            the writer where the help should be written
 */
public void printHelp(final PrintWriter out) {
    HelpFormatter hf = new HelpFormatter();
    StringBuilder sbDivider = new StringBuilder("=");
    while (sbDivider.length() < hf.getPageWidth()) {
        sbDivider.append('=');
    }
    out.println(sbDivider.toString());
    out.println("PLUGIN NAME : " + proxyedPluginDefinition.getName());
    if (description != null && description.trim().length() != 0) {
        out.println(sbDivider.toString());
        out.println("Description : ");
        out.println();
        out.println(description);
    }

    hf.setGroup(mainOptionsGroup);
    // hf.setHeader(m_pluginDef.getName());
    hf.setDivider(sbDivider.toString());
    hf.setPrintWriter(out);
    hf.print();
    // hf.printHelp(m_pluginDef.getName(), m_Options);
}