Example usage for org.apache.commons.cli ParseException ParseException

List of usage examples for org.apache.commons.cli ParseException ParseException

Introduction

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

Prototype

public ParseException(String message) 

Source Link

Document

Construct a new ParseException with the specified detail message.

Usage

From source file:org.apache.hadoop.hive.metastore.tools.SchemaToolCommandLine.java

private void printAndExit(String reason) throws ParseException {
    if (reason != null) {
        System.err.println(reason);
    }/*from   www . j a  v  a 2  s . co  m*/
    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp("schemaTool", cmdLineOptions);
    if (reason != null) {
        throw new ParseException(reason);
    } else {
        System.exit(0);
    }
}

From source file:org.apache.james.cli.ServerCmd.java

@VisibleForTesting
static int getPort(CommandLine cmd) throws ParseException {
    String portNum = cmd.getOptionValue(PORT_OPT_LONG);
    if (portNum != null) {
        try {//from w w w .  j  ava  2s.c o m
            return validatePortNumber(Integer.parseInt(portNum));
        } catch (NumberFormatException e) {
            throw new ParseException("Port must be a number");
        }
    }
    return DEFAULT_PORT;
}

From source file:org.apache.marmotta.loader.core.MarmottaLoader.java

public static Configuration parseOptions(String[] args) throws ParseException {
    Options options = buildOptions();//  w  w w. j  av  a  2s.  c o  m

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);

    Configuration result = new MapConfiguration(new HashMap<String, Object>());

    if (cmd.hasOption('B')) {
        // check backends
        Set<String> existing = Sets
                .newHashSet(Iterators.transform(backends.iterator(), new BackendIdentifierFunction()));
        if (!existing.contains(cmd.getOptionValue('B'))) {
            throw new ParseException("the backend " + cmd.getOptionValue('B') + " does not exist");
        }

        result.setProperty(LoaderOptions.BACKEND, cmd.getOptionValue('B'));
    }

    if (cmd.hasOption('b')) {
        result.setProperty(LoaderOptions.BASE_URI, cmd.getOptionValue('b'));
    }

    if (cmd.hasOption('z')) {
        result.setProperty(LoaderOptions.COMPRESSION, CompressorStreamFactory.GZIP);
    }

    if (cmd.hasOption('j')) {
        result.setProperty(LoaderOptions.COMPRESSION, CompressorStreamFactory.BZIP2);
    }

    if (cmd.hasOption('c')) {
        result.setProperty(LoaderOptions.CONTEXT, cmd.getOptionValue('c'));
    }

    if (cmd.hasOption('t')) {
        RDFFormat fmt = getRDFFormat(cmd.getOptionValue('t'));
        if (fmt == null) {
            throw new ParseException("unrecognized MIME type: " + cmd.getOptionValue('t'));
        }

        result.setProperty(LoaderOptions.FORMAT, fmt.getDefaultMIMEType());
    }

    if (cmd.hasOption('f')) {
        result.setProperty(LoaderOptions.FILES, Arrays.asList(cmd.getOptionValues('f')));
    }

    if (cmd.hasOption('d')) {
        result.setProperty(LoaderOptions.DIRS, Arrays.asList(cmd.getOptionValues('d')));
    }

    if (cmd.hasOption('a')) {
        result.setProperty(LoaderOptions.ARCHIVES, Arrays.asList(cmd.getOptionValues('a')));
    }

    if (cmd.hasOption('s')) {
        result.setProperty(LoaderOptions.STATISTICS_ENABLED, true);
        result.setProperty(LoaderOptions.STATISTICS_GRAPH, cmd.getOptionValue('s'));
    }

    if (cmd.hasOption('D')) {
        for (Map.Entry e : cmd.getOptionProperties("D").entrySet()) {
            result.setProperty(e.getKey().toString(), e.getValue());
        }
    }

    for (LoaderBackend b : backends) {
        for (Option option : b.getOptions()) {
            if (cmd.hasOption(option.getOpt())) {
                String key = String.format("backend.%s.%s", b.getIdentifier(),
                        option.getLongOpt() != null ? option.getLongOpt() : option.getOpt());
                if (option.hasArg()) {
                    if (option.hasArgs()) {
                        result.setProperty(key, Arrays.asList(cmd.getOptionValues(option.getOpt())));
                    } else {
                        result.setProperty(key, cmd.getOptionValue(option.getOpt()));
                    }
                } else {
                    result.setProperty(key, true);
                }
            }
        }
    }

    return result;
}

From source file:org.apache.maven.cli.MavenCli.java

void cli(CliRequest cliRequest) throws Exception {
    ///*w  w w .jav a 2s  .  c  om*/
    // Parsing errors can happen during the processing of the arguments and we prefer not having to check if
    // the logger is null and construct this so we can use an SLF4J logger everywhere.
    //
    slf4jLogger = new Slf4jStdoutLogger();

    CLIManager cliManager = new CLIManager();

    List<String> args = new ArrayList<>();

    try {
        File configFile = new File(cliRequest.multiModuleProjectDirectory, MVN_MAVEN_CONFIG);

        if (configFile.isFile()) {
            for (String arg : Files.toString(configFile, Charsets.UTF_8).split("\\s+")) {
                if (!arg.isEmpty()) {
                    args.add(arg);
                }
            }

            CommandLine config = cliManager.parse(args.toArray(new String[args.size()]));
            List<?> unrecongized = config.getArgList();
            if (!unrecongized.isEmpty()) {
                throw new ParseException("Unrecognized maven.config entries: " + unrecongized);
            }
        }
    } catch (ParseException e) {
        System.err.println("Unable to parse maven.config: " + e.getMessage());
        cliManager.displayHelp(System.out);
        throw e;
    }

    try {
        args.addAll(0, Arrays.asList(cliRequest.args));
        cliRequest.commandLine = cliManager.parse(args.toArray(new String[args.size()]));
    } catch (ParseException e) {
        System.err.println("Unable to parse command line options: " + e.getMessage());
        cliManager.displayHelp(System.out);
        throw e;
    }

    if (cliRequest.commandLine.hasOption(CLIManager.HELP)) {
        cliManager.displayHelp(System.out);
        throw new ExitException(0);
    }

    if (cliRequest.commandLine.hasOption(CLIManager.VERSION)) {
        System.out.println(CLIReportingUtils.showVersion());
        throw new ExitException(0);
    }
}

From source file:org.apache.mnemonic.bench.Sort.java

public static void main(String[] args) throws Exception {

    Options options = new Options();

    Option mode = new Option("m", "mode", true, "run mode [A|B]");
    mode.setRequired(true);//w ww  . j a va  2  s.  c o  m
    options.addOption(mode);

    Option input = new Option("i", "input", true, "input file path");
    input.setRequired(true);
    options.addOption(input);

    Option output = new Option("o", "output", true, "output file");
    output.setRequired(true);
    options.addOption(output);

    CommandLineParser parser = new DefaultParser();
    HelpFormatter formatter = new HelpFormatter();
    CommandLine cmd;

    String runMode, inputFilePath, outputFilePath;

    try {
        cmd = parser.parse(options, args);
        runMode = cmd.getOptionValue("mode");
        inputFilePath = cmd.getOptionValue("input");
        outputFilePath = cmd.getOptionValue("output");
        if (!runMode.equals("A") && !runMode.equals("B")) {
            throw new ParseException("Run mode is not specified correctly, Please use A or B as run mode.");
        }
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        formatter.printHelp("Sort-bench", options);
        System.exit(1);
        return;
    }
    MDC.put("mode", String.format("Mode-%s", runMode));

    LOGGER.info("Run Mode : {}", runMode);
    LOGGER.info("Input file : {}", inputFilePath);
    LOGGER.info("Output file : {}", outputFilePath);

    File inputFile = new File(inputFilePath);
    File outputFile = new File(outputFilePath);

    BufferedReader reader = null;
    BufferedWriter writer = null;

    TextFileSort tfsorter = null;

    long sttime;

    try {
        reader = new BufferedReader(new FileReader(inputFile));
        writer = new BufferedWriter(new FileWriter(outputFile));
        if (runMode.equals("A")) {
            /* regular way */
            tfsorter = new RegularTestFileSort();
        } else {
            /* mnemonic way */
            tfsorter = new DNCSTextFileSort();
        }

        sttime = System.nanoTime();
        tfsorter.load(reader);
        reportElapse("Load Time", sttime, System.nanoTime());
        sttime = System.nanoTime();
        tfsorter.doSort();
        reportElapse("Sort Time", sttime, System.nanoTime());
        sttime = System.nanoTime();
        tfsorter.store(writer);
        reportElapse("Store Time", sttime, System.nanoTime());
        reportSortInfo(tfsorter.getSortInfo());
        tfsorter.clear();
    } catch (FileNotFoundException e) {
        System.err.println(e.getMessage());
        throw e;
    } catch (IOException e) {
        System.err.println(e.getMessage());
        throw e;
    } finally {
        try {
            if (null != reader) {
                reader.close();
            }
            if (null != writer) {
                writer.close();
            }
        } catch (IOException e) {
            System.err.println(e.getMessage());
            throw e;
        }
    }
}

From source file:org.apache.nifi.toolkit.s2s.SiteToSiteCliMain.java

/**
 * Parses command line options into a CliParse object
 *
 * @param options an empty options object (so callers can print usage if the parse fails
 * @param args    the string array of arguments
 * @return a CliParse object containing the constructed SiteToSiteClient.Builder and a TransferDirection
 * @throws ParseException if there is an error parsing the command line
 *///from  w  w  w. j  av  a2 s .c o  m
public static CliParse parseCli(Options options, String[] args) throws ParseException {
    options.addOption("u", URL_OPTION, true, "NiFI URL to connect to (default: " + URL_OPTION_DEFAULT + ")");
    options.addOption("d", DIRECTION_OPTION, true, "Direction (valid directions: "
            + Arrays.stream(TransferDirection.values()).map(Object::toString).collect(Collectors.joining(", "))
            + ") (default: " + DIRECTION_OPTION_DEFAULT + ")");
    options.addOption("n", PORT_NAME_OPTION, true, "Port name");
    options.addOption("i", PORT_IDENTIFIER_OPTION, true, "Port id");
    options.addOption(null, TIMEOUT_OPTION, true, "Timeout");
    options.addOption(null, PENALIZATION_OPTION, true, "Penalization period");
    options.addOption(null, KEYSTORE_OPTION, true, "Keystore");
    options.addOption(null, KEY_STORE_TYPE_OPTION, true,
            "Keystore type (default: " + KEYSTORE_TYPE_OPTION_DEFAULT + ")");
    options.addOption(null, KEY_STORE_PASSWORD_OPTION, true, "Keystore password");
    options.addOption(null, TRUST_STORE_OPTION, true, "Truststore");
    options.addOption(null, TRUST_STORE_TYPE_OPTION, true,
            "Truststore type (default: " + KEYSTORE_TYPE_OPTION_DEFAULT + ")");
    options.addOption(null, TRUST_STORE_PASSWORD_OPTION, true, "Truststore password");
    options.addOption(null, NEED_CLIENT_AUTH_OPTION, false, "Need client auth");
    options.addOption("c", COMPRESSION_OPTION, false, "Use compression");
    options.addOption(null, PEER_PERSISTENCE_FILE_OPTION, true,
            "File to write peer information to so it can be recovered on restart");
    options.addOption("p", TRANSPORT_PROTOCOL_OPTION, true,
            "Site to site transport protocol (default: " + TRANSPORT_PROTOCOL_OPTION_DEFAULT + ")");
    options.addOption(null, BATCH_COUNT_OPTION, true, "Number of flow files in a batch");
    options.addOption(null, BATCH_SIZE_OPTION, true, "Size of flow files in a batch");
    options.addOption(null, BATCH_DURATION_OPTION, true, "Duration of a batch");
    options.addOption(null, PROXY_HOST_OPTION, true, "Proxy hostname");
    options.addOption(null, PROXY_PORT_OPTION, true, "Proxy port");
    options.addOption(null, PROXY_USERNAME_OPTION, true, "Proxy username");
    options.addOption(null, PROXY_PASSWORD_OPTION, true, "Proxy password");
    options.addOption("h", HELP_OPTION, false, "Show help message and exit");
    CommandLineParser parser = new DefaultParser();
    CommandLine commandLine;
    commandLine = parser.parse(options, args);
    if (commandLine.hasOption(HELP_OPTION)) {
        printUsage(null, options);
        System.exit(1);
    }
    SiteToSiteClient.Builder builder = new SiteToSiteClient.Builder();
    builder.url(commandLine.getOptionValue(URL_OPTION, URL_OPTION_DEFAULT));
    if (commandLine.hasOption(PORT_NAME_OPTION)) {
        builder.portName(commandLine.getOptionValue(PORT_NAME_OPTION));
    }
    if (commandLine.hasOption(PORT_IDENTIFIER_OPTION)) {
        builder.portIdentifier(commandLine.getOptionValue(PORT_IDENTIFIER_OPTION));
    }
    if (commandLine.hasOption(TIMEOUT_OPTION)) {
        builder.timeout(
                FormatUtils.getTimeDuration(commandLine.getOptionValue(TIMEOUT_OPTION), TimeUnit.NANOSECONDS),
                TimeUnit.NANOSECONDS);
    }
    if (commandLine.hasOption(PENALIZATION_OPTION)) {
        builder.nodePenalizationPeriod(FormatUtils.getTimeDuration(
                commandLine.getOptionValue(PENALIZATION_OPTION), TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
    }
    if (commandLine.hasOption(KEYSTORE_OPTION)) {
        builder.keystoreFilename(commandLine.getOptionValue(KEYSTORE_OPTION));
        builder.keystoreType(KeystoreType.valueOf(
                commandLine.getOptionValue(KEY_STORE_TYPE_OPTION, KEYSTORE_TYPE_OPTION_DEFAULT).toUpperCase()));

        if (commandLine.hasOption(KEY_STORE_PASSWORD_OPTION)) {
            builder.keystorePass(commandLine.getOptionValue(KEY_STORE_PASSWORD_OPTION));
        } else {
            throw new ParseException("Must specify keystore password");
        }
    }
    if (commandLine.hasOption(TRUST_STORE_OPTION)) {
        builder.truststoreFilename(commandLine.getOptionValue(TRUST_STORE_OPTION));
        builder.truststoreType(KeystoreType.valueOf(commandLine
                .getOptionValue(TRUST_STORE_TYPE_OPTION, KEYSTORE_TYPE_OPTION_DEFAULT).toUpperCase()));

        if (commandLine.hasOption(TRUST_STORE_PASSWORD_OPTION)) {
            builder.truststorePass(commandLine.getOptionValue(TRUST_STORE_PASSWORD_OPTION));
        } else {
            throw new ParseException("Must specify truststore password");
        }
    }
    if (commandLine.hasOption(COMPRESSION_OPTION)) {
        builder.useCompression(true);
    } else {
        builder.useCompression(false);
    }
    if (commandLine.hasOption(PEER_PERSISTENCE_FILE_OPTION)) {
        builder.peerPersistenceFile(new File(commandLine.getOptionValue(PEER_PERSISTENCE_FILE_OPTION)));
    }
    if (commandLine.hasOption(BATCH_COUNT_OPTION)) {
        builder.requestBatchCount(Integer.parseInt(commandLine.getOptionValue(BATCH_COUNT_OPTION)));
    }
    if (commandLine.hasOption(BATCH_SIZE_OPTION)) {
        builder.requestBatchSize(Long.parseLong(commandLine.getOptionValue(BATCH_SIZE_OPTION)));
    }
    if (commandLine.hasOption(BATCH_DURATION_OPTION)) {
        builder.requestBatchDuration(FormatUtils.getTimeDuration(
                commandLine.getOptionValue(BATCH_DURATION_OPTION), TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
    }
    if (commandLine.hasOption(PROXY_HOST_OPTION)) {
        builder.httpProxy(new HttpProxy(commandLine.getOptionValue(PROXY_HOST_OPTION),
                Integer.parseInt(commandLine.getOptionValue(PROXY_PORT_OPTION, PROXY_PORT_OPTION_DEFAULT)),
                commandLine.getOptionValue(PROXY_USERNAME_OPTION),
                commandLine.getOptionValue(PROXY_PASSWORD_OPTION)));
    }
    builder.transportProtocol(SiteToSiteTransportProtocol.valueOf(commandLine
            .getOptionValue(TRANSPORT_PROTOCOL_OPTION, TRANSPORT_PROTOCOL_OPTION_DEFAULT).toUpperCase()));
    TransferDirection transferDirection = TransferDirection
            .valueOf(commandLine.getOptionValue(DIRECTION_OPTION, DIRECTION_OPTION_DEFAULT));
    return new CliParse() {
        @Override
        public SiteToSiteClient.Builder getBuilder() {
            return builder;
        }

        @Override
        public TransferDirection getTransferDirection() {
            return transferDirection;
        }
    };
}

From source file:org.apache.oozie.cli.CLIParser.java

/**
 * Parse a array of arguments into a command.
 *
 * @param args array of arguments./*from  w w w.  ja v a2 s  .c  o m*/
 * @return the parsed Command.
 * @throws ParseException thrown if the arguments could not be parsed.
 */
public Command parse(String[] args) throws ParseException {
    if (args.length == 0) {
        throw new ParseException("missing sub-command");
    } else {
        if (commands.containsKey(args[0])) {
            GnuParser parser;
            String[] minusCommand = new String[args.length - 1];
            System.arraycopy(args, 1, minusCommand, 0, minusCommand.length);

            if (args[0].equals(OozieCLI.JOB_CMD)) {
                validdateArgs(args, minusCommand);
                parser = new OozieGnuParser(true);
            } else {
                parser = new OozieGnuParser(false);
            }

            return new Command(args[0],
                    parser.parse(commands.get(args[0]), minusCommand, commandWithArgs.get(args[0])));
        } else {
            throw new ParseException(MessageFormat.format("invalid sub-command [{0}]", args[0]));
        }
    }
}

From source file:org.apache.openaz.xacml.pdp.test.policy.TestPolicy.java

@Override
protected void parseCommands(String[] args) throws ParseException, MalformedURLException, HelpException {
    ////  www .  ja  v  a2 s  .  com
    // Have our super do its job
    //
    super.parseCommands(args);
    //
    // Look for the policy option
    //
    CommandLine cl = new DefaultParser().parse(options, args);
    if (cl.hasOption(OPTION_POLICY)) {
        this.policy = Paths.get(cl.getOptionValue(OPTION_POLICY));
        //
        // Ensure it exists
        //
        if (Files.notExists(this.policy)) {
            throw new ParseException("Policy file does not exist.");
        }
    } else {
        throw new ParseException("You need to specify the policy file to be used.");
    }
    if (cl.hasOption(OPTION_SKIP_GENERATE)) {
        this.skip = true;
    } else {
        this.skip = false;
    }
}

From source file:org.apache.reef.tang.formats.CommandLine.java

/**
 * Utility method to quickly parse a command line to a ConfigurationBuilder.
 * <p>/*from  w w w .j av  a2 s . co m*/
 * This is equivalent to
 * <code>new CommandLine().processCommandLine(args, argClasses).getBuilder()</code>, but with additional checks.
 *
 * @param args       the command line parameters to parse.
 * @param argClasses the named parameters to look for.
 * @return a ConfigurationBuilder with the parsed parameters
 * @throws ParseException if the parsing  of the commandline fails.
 */

// ParseException constructor does not accept a cause Exception, hence
@SuppressWarnings("checkstyle:avoidhidingcauseexception")
public static ConfigurationBuilder parseToConfigurationBuilder(final String[] args,
        final Class<? extends Name<?>>... argClasses) throws ParseException {
    final CommandLine commandLine;
    try {
        commandLine = new CommandLine().processCommandLine(args, argClasses);
    } catch (final IOException e) {
        // processCommandLine() converts ParseException into IOException. This reverts that to make exception handling
        // more straight forward.
        throw new ParseException(e.getMessage());
    }

    // processCommandLine() indicates that it might return null. We need to guard users of this one from that
    if (commandLine == null) {
        throw new ParseException("Unable to parse the command line and the parser returned null.");
    } else {
        return commandLine.getBuilder();
    }
}

From source file:org.apache.sentry.binding.hive.authz.SentryConfigTool.java

/**
 * parse arguments// w w  w.  j  a  v  a  2s. com
 * 
 * <pre>
 *   -d,--debug                  Enable debug output
 *   -e,--query <arg>            Query privilege verification, requires -u
 *   -h,--help                   Print usage
 *   -i,--policyIni <arg>        Policy file path
 *   -j,--jdbcURL <arg>          JDBC URL
 *   -l,--listPrivs,--listPerms  List privilges for given user, requires -u
 *   -p,--password <arg>         Password
 *   -s,--sentry-site <arg>      sentry-site file path
 *   -u,--user <arg>             user name
 *   -v,--validate               Validate policy file
 *   -I,--import                 Import policy file
 *   -E,--export                 Export policy file
 *   -o,--overwrite              Overwrite the exist role data when do the import
 * </pre>
 * 
 * @param args
 */
private void parseArgs(String[] args) {
    boolean enableDebug = false;

    Options sentryOptions = new Options();

    Option helpOpt = new Option("h", "help", false, "Print usage");
    helpOpt.setRequired(false);

    Option validateOpt = new Option("v", "validate", false, "Validate policy file");
    validateOpt.setRequired(false);

    Option queryOpt = new Option("e", "query", true, "Query privilege verification, requires -u");
    queryOpt.setRequired(false);

    Option listPermsOpt = new Option("l", "listPerms", false, "list permissions for given user, requires -u");
    listPermsOpt.setRequired(false);
    Option listPrivsOpt = new Option("listPrivs", false, "list privileges for given user, requires -u");
    listPrivsOpt.setRequired(false);

    Option importOpt = new Option("I", "import", true, "Import policy file");
    importOpt.setRequired(false);

    Option exportOpt = new Option("E", "export", true, "Export policy file");
    exportOpt.setRequired(false);
    // required args
    OptionGroup sentryOptGroup = new OptionGroup();
    sentryOptGroup.addOption(helpOpt);
    sentryOptGroup.addOption(validateOpt);
    sentryOptGroup.addOption(queryOpt);
    sentryOptGroup.addOption(listPermsOpt);
    sentryOptGroup.addOption(listPrivsOpt);
    sentryOptGroup.addOption(importOpt);
    sentryOptGroup.addOption(exportOpt);
    sentryOptGroup.setRequired(true);
    sentryOptions.addOptionGroup(sentryOptGroup);

    // optional args
    Option jdbcArg = new Option("j", "jdbcURL", true, "JDBC URL");
    jdbcArg.setRequired(false);
    sentryOptions.addOption(jdbcArg);

    Option sentrySitePath = new Option("s", "sentry-site", true, "sentry-site file path");
    sentrySitePath.setRequired(false);
    sentryOptions.addOption(sentrySitePath);

    Option globalPolicyPath = new Option("i", "policyIni", true, "Policy file path");
    globalPolicyPath.setRequired(false);
    sentryOptions.addOption(globalPolicyPath);

    Option userOpt = new Option("u", "user", true, "user name");
    userOpt.setRequired(false);
    sentryOptions.addOption(userOpt);

    Option passWordOpt = new Option("p", "password", true, "Password");
    userOpt.setRequired(false);
    sentryOptions.addOption(passWordOpt);

    Option debugOpt = new Option("d", "debug", false, "enable debug output");
    debugOpt.setRequired(false);
    sentryOptions.addOption(debugOpt);

    Option overwriteOpt = new Option("o", "overwrite", false, "enable import overwrite");
    overwriteOpt.setRequired(false);
    sentryOptions.addOption(overwriteOpt);

    try {
        Parser parser = new GnuParser();
        CommandLine cmd = parser.parse(sentryOptions, args);

        for (Option opt : cmd.getOptions()) {
            if (opt.getOpt().equals("s")) {
                setSentrySiteFile(opt.getValue());
            } else if (opt.getOpt().equals("i")) {
                setPolicyFile(opt.getValue());
            } else if (opt.getOpt().equals("e")) {
                setQuery(opt.getValue());
            } else if (opt.getOpt().equals("j")) {
                setJdbcURL(opt.getValue());
            } else if (opt.getOpt().equals("u")) {
                setUser(opt.getValue());
            } else if (opt.getOpt().equals("p")) {
                setPassWord(opt.getValue());
            } else if (opt.getOpt().equals("l") || opt.getOpt().equals("listPrivs")) {
                setListPrivs(true);
            } else if (opt.getOpt().equals("v")) {
                setValidate(true);
            } else if (opt.getOpt().equals("I")) {
                setImportPolicyFilePath(opt.getValue());
            } else if (opt.getOpt().equals("E")) {
                setExportPolicyFilePath(opt.getValue());
            } else if (opt.getOpt().equals("h")) {
                usage(sentryOptions);
            } else if (opt.getOpt().equals("d")) {
                enableDebug = true;
            } else if (opt.getOpt().equals("o")) {
                setImportOverwriteRole(true);
            }
        }

        if (isListPrivs() && (getUser() == null)) {
            throw new ParseException("Can't use -l without -u ");
        }
        if ((getQuery() != null) && (getUser() == null)) {
            throw new ParseException("Must use -u with -e ");
        }
    } catch (ParseException e1) {
        usage(sentryOptions);
    }

    if (!enableDebug) {
        // turn off log
        LogManager.getRootLogger().setLevel(Level.OFF);
    }
}