Example usage for org.apache.commons.cli AlreadySelectedException getMessage

List of usage examples for org.apache.commons.cli AlreadySelectedException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.cli AlreadySelectedException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.modeln.build.common.tool.CMnCmdLineTool.java

/**
 * Parse the command line arguments.//  w  w  w  . j a  v  a  2 s  . c  om
 */
protected static CommandLine parseArgs(String[] args) {
    CommandLine cl = null;
    try {
        cl = argParser.parse(cmdOptions, args);
    } catch (AlreadySelectedException dupex) {
        displayHelp();
        display("\nDuplicate option: " + dupex.getMessage());
    } catch (MissingOptionException opex) {
        displayHelp();
        display("\nMissing command line option: " + opex.getMessage());
    } catch (UnrecognizedOptionException uex) {
        displayHelp();
        display(uex.getMessage());
    } catch (ParseException pe) {
        display("Unable to parse the command line arguments: " + pe);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return cl;
}

From source file:org.apache.directory.server.tools.BaseCommand.java

public CommandLine getCommandLine(String command, String[] args) {
    Options all = allOptions(command);/*from  w w  w . ja v a  2  s.  c o m*/
    CommandLineParser parser = new PosixParser();
    CommandLine cmdline = null;
    try {
        cmdline = parser.parse(all, args);
    } catch (AlreadySelectedException ase) {
        System.err.println("Command line parsing failed for " + command + ".  Reason: already selected "
                + ase.getMessage());
        System.exit(1);
    } catch (MissingArgumentException mae) {
        System.err.println("Command line parsing failed for " + command + ".  Reason: missing argument "
                + mae.getMessage());
        System.exit(1);
    } catch (MissingOptionException moe) {
        System.err.println(
                "Command line parsing failed for " + command + ".  Reason: missing option " + moe.getMessage());
        System.exit(1);
    } catch (UnrecognizedOptionException uoe) {
        System.err.println("Command line parsing failed for " + command + ".  Reason: unrecognized option"
                + uoe.getMessage());
        System.exit(1);
    } catch (ParseException pe) {
        System.err.println("Command line parsing failed for " + command + ".  Reason: " + pe.getClass());
        System.exit(1);
    }

    return cmdline;
}

From source file:ru.taximaxim.dbreplicator2.cli.AbstractCommandLineParser.java

/**
 * parser command line/*from  w w  w  .  j a  v  a 2s  .  co  m*/
 *
 * @param args
 */
protected void parserCommandLine(String[] args) {

    CommandLineParser cmdLinePosixParser = new PosixParser();
    CommandLine commandLine = null;
    try {
        commandLine = cmdLinePosixParser.parse(getOptions(), args);
        processingCmd(commandLine);
    } catch (AlreadySelectedException ex) {
        LOG.error(String.format("  : %s", ex.getMessage()), ex);
    } catch (ParseException ex) {
        LOG.error("? ??? ", ex);
    }
}