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

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

Introduction

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

Prototype

public void setException(OptionException exception) 

Source Link

Document

Sets the exception to document

Usage

From source file:org.apache.mahout.common.CommandLineUtil.java

public static void printHelpWithGenericOptions(Group group, OptionException oe) throws IOException {
    new GenericOptionsParser(new Configuration(), new org.apache.commons.cli.Options(), new String[0]);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charsets.UTF_8), true);
    HelpFormatter formatter = new HelpFormatter();
    formatter.setGroup(group);/*from w  ww  .  j ava2  s.c om*/
    formatter.setPrintWriter(pw);
    formatter.setException(oe);
    formatter.print();
}

From source file:org.opencloudengine.flamingo.mapreduce.util.CommandLineUtil.java

public static void printHelpWithGenericOptions(Group group, OptionException oe) throws IOException {
    Options ops = new Options();
    new GenericOptionsParser(new Configuration(), ops, new String[0]);
    org.apache.commons.cli.HelpFormatter fmt = new org.apache.commons.cli.HelpFormatter();
    fmt.printHelp("<command> [Generic Options] [Job-Specific Options]", "Generic Options:", ops, "");

    PrintWriter pw = new PrintWriter(System.out, true);
    HelpFormatter formatter = new HelpFormatter();
    formatter.setGroup(group);//from w w  w. j  a  va 2  s .  c  o m
    formatter.setPrintWriter(pw);
    formatter.setException(oe);
    formatter.print();
    pw.flush();
}