Example usage for org.apache.commons.cli MissingOptionException getCause

List of usage examples for org.apache.commons.cli MissingOptionException getCause

Introduction

In this page you can find the example usage for org.apache.commons.cli MissingOptionException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:net.ninjacat.stubborn.Stubborn.java

public static void main(String[] argv) throws ClassNotFoundException, ParseException {
    Options options = createOptions();/*from   w ww.j  a  va2  s  . c o  m*/
    if (argv.length == 0) {
        printHelp(options);
        return;
    }

    Class.forName(Bootstrapper.class.getCanonicalName());
    CommandLineParser parser = new GnuParser();

    try {
        CommandLine commandLine = parser.parse(options, argv);
        if (commandLine.hasOption("h")) {
            printHelp(options);
            return;
        }

        Context context = new Context(commandLine);

        Transformer transformer = Bootstrapper.get(Transformer.class);

        transformer.transform(context);
    } catch (MissingOptionException ex) {
        System.out.println("Missing required parameter " + ex.getMissingOptions());
        printHelp(options);
    } catch (TransformationException ex) {
        System.out.println("Failed to perform transformation caused by " + ex.getCause());
        System.out.println(ex.getMessage());
    }
}