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

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

Introduction

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

Prototype

public void printUsage() 

Source Link

Document

Prints a single line of usage information (wrapping if necessary)

Usage

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

public String getCommandLine() {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();

    Group g = getCommandLineGroup();
    HelpFormatter hf = new HelpFormatter(null, null, null, getConsole().getTerminal().getWidth());
    hf.setGroup(g);/*  w ww .  j  a  v a  2 s. c o m*/
    hf.setPrintWriter(new PrintWriter(new OutputStreamWriter(bout, charset)));
    hf.printUsage();

    String usage = new String(bout.toByteArray(), charset);

    String[] lines = usage.split("\\n");

    StringBuilder res = new StringBuilder();

    for (int i = 1; i < lines.length; i++) {
        res.append(lines[i]);
    }

    return res.toString();
}