org.apache.commons.cli2.util.HelpFormatter Java Examples

The following examples show how to use org.apache.commons.cli2.util.HelpFormatter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: jackrabbit-filevault   Author: apache   File: AbstractApplication.java    License: Apache License 2.0 6 votes vote down vote up
protected HelpFormatter getAppHelpFormatter() {
    CliHelpFormatter hf = CliHelpFormatter.create();
    StringBuffer sep = new StringBuffer(hf.getPageWidth());
    while (sep.length() < hf.getPageWidth()) {
        sep.append("-");
    }
    hf.setHeader(getVersionString());
    hf.setDivider(sep.toString());
    hf.setShellCommand("  " + getShellCommand() + " [options] <command> [arg1 [arg2 [arg3] ..]]");
    hf.setGroup(getApplicationCLGroup());
    hf.setSkipToplevel(true);
    hf.getFullUsageSettings().removeAll(DisplaySetting.ALL);

    hf.getDisplaySettings().remove(DisplaySetting.DISPLAY_GROUP_ARGUMENT);
    hf.getDisplaySettings().remove(DisplaySetting.DISPLAY_PARENT_CHILDREN);
    hf.getDisplaySettings().add(DisplaySetting.DISPLAY_OPTIONAL);

    hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_PROPERTY_OPTION);
    hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_PARENT_ARGUMENT);
    hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_ARGUMENT_BRACKETED);
    return hf;
}
 
Example #2
Source Project: jackrabbit-filevault   Author: apache   File: ExecutionContext.java    License: Apache License 2.0 5 votes vote down vote up
protected HelpFormatter getCmdHelpFormatter(CliCommand cmd) {
    CliHelpFormatter hf = CliHelpFormatter.create();
    if (cmd != null) {
        hf.setCmd(cmd);
        hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_ARGUMENT_BRACKETED);
    } else {
        hf.setGroup(getCommandsGroup());
        hf.setShowUsage(false);
        hf.getDisplaySettings().remove(DisplaySetting.DISPLAY_PARENT_CHILDREN);
    }
    return hf;
}
 
Example #3
Source Project: jackrabbit-filevault   Author: apache   File: CliHelpFormatter.java    License: Apache License 2.0 4 votes vote down vote up
public static CliHelpFormatter create() {
    return new CliHelpFormatter(HelpFormatter.DEFAULT_GUTTER_LEFT,
            HelpFormatter.DEFAULT_GUTTER_CENTER,
            HelpFormatter.DEFAULT_GUTTER_RIGHT,
            getDefaultWidth());
}
 
Example #4
Source Project: jackrabbit-filevault   Author: apache   File: CliHelpFormatter.java    License: Apache License 2.0 4 votes vote down vote up
private static int getDefaultWidth() {
    int w = Integer.getInteger(SYS_PROP_TERM_WIDTH, HelpFormatter.DEFAULT_FULL_WIDTH).intValue();
    return Math.max(w, HelpFormatter.DEFAULT_FULL_WIDTH);
}