List of usage examples for org.apache.commons.cli OptionBuilder withLongOpt
public static OptionBuilder withLongOpt(String newLongopt)
From source file:org.apache.orc.tools.Driver.java
@SuppressWarnings("static-access") static Options createOptions() { Options result = new Options(); result.addOption(OptionBuilder.withLongOpt("help").withDescription("Print help message").create('h')); result.addOption(OptionBuilder.withLongOpt("define").withDescription("Set a configuration property") .hasArg().withValueSeparator().create('D')); return result; }
From source file:org.apache.orc.tools.FileDump.java
@SuppressWarnings("static-access") static Options createOptions() { Options result = new Options(); // add -d and --data to print the rows result.addOption(// w w w. j a va 2 s. co m OptionBuilder.withLongOpt("data").withDescription("Should the data be printed").create('d')); // to avoid breaking unit tests (when run in different time zones) for file dump, printing // of timezone is made optional result.addOption( OptionBuilder.withLongOpt("timezone").withDescription("Print writer's time zone").create('t')); result.addOption(OptionBuilder.withLongOpt("help").withDescription("print help message").create('h')); result.addOption(OptionBuilder.withLongOpt("rowindex") .withArgName("comma separated list of column ids for which row index should be printed") .withDescription("Dump stats for column number(s)").hasArg().create('r')); result.addOption( OptionBuilder.withLongOpt("json").withDescription("Print metadata in JSON format").create('j')); result.addOption(OptionBuilder.withLongOpt("pretty").withDescription("Pretty print json metadata output") .create('p')); result.addOption(OptionBuilder.withLongOpt("recover") .withDescription("recover corrupted orc files generated by streaming").create()); result.addOption(OptionBuilder.withLongOpt("skip-dump") .withDescription("used along with --recover to directly recover files without dumping").create()); result.addOption(OptionBuilder.withLongOpt("backup-path") .withDescription("specify a backup path to store the corrupted files (default: /tmp)").hasArg() .create()); return result; }
From source file:org.apache.poi.ss.examples.ToCSV.java
@SuppressWarnings("static-access") private static Options getOptions() { Options options = new Options(); options.addOption(//from ww w. j a va2 s . com OptionBuilder.withLongOpt("help").withDescription("Prints this help message.").create("h")); options.addOption(OptionBuilder.withLongOpt("row-limit") .withDescription( "Rows limit per sheet. Default unlimited (-1). " + "Will produce preview file per sheet.") .hasArg().create("r")); options.addOption(OptionBuilder.withLongOpt("separator") .withDescription("Optional. The character or characters that " + "should be used to separate fields in the CSV " + "record. If no value is passed then the comma " + "will be assumed.") .hasArg().create("s")); options.addOption(OptionBuilder.withLongOpt("format") .withDescription("Optional. This argument can take one of two " + "values. Passing 0 (zero) will result in a CSV " + "file that obeys Excel's formatting conventions " + "whilst passing 1 (one) will result in a file " + "that obeys UNIX formatting conventions. If no " + "value is passed, then the CSV file produced " + "will obey Excel's formatting conventions.") .hasArg().create("f")); return options; }
From source file:org.apache.qpid.amqp_1_0.client.Util.java
protected Util(String[] args) { CommandLineParser cmdLineParse = new PosixParser(); Options options = new Options(); options.addOption("h", "help", false, "show this help message and exit"); options.addOption(OptionBuilder.withLongOpt("host").withDescription("host to connect to (default 0.0.0.0)") .hasArg(true).withArgName("HOST").create('H')); options.addOption(//from w w w .j a va 2 s .co m OptionBuilder.withLongOpt("username").withDescription("username to use for authentication") .hasArg(true).withArgName("USERNAME").create('u')); options.addOption( OptionBuilder.withLongOpt("password").withDescription("password to use for authentication") .hasArg(true).withArgName("PASSWORD").create('w')); options.addOption(OptionBuilder.withLongOpt("port").withDescription("port to connect to (default 5672)") .hasArg(true).withArgName("PORT").create('p')); options.addOption(OptionBuilder.withLongOpt("frame-size").withDescription("specify the maximum frame size") .hasArg(true).withArgName("FRAME_SIZE").create('f')); options.addOption(OptionBuilder.withLongOpt("container-name").withDescription("Container name").hasArg(true) .withArgName("CONTAINER_NAME").create('C')); options.addOption(OptionBuilder.withLongOpt("ssl").withDescription("Use SSL").create('S')); options.addOption( OptionBuilder.withLongOpt("remote-hostname").withDescription("hostname to supply in the open frame") .hasArg(true).withArgName("HOST").create('O')); if (hasBlockOption()) options.addOption( OptionBuilder.withLongOpt("block").withDescription("block until messages arrive").create('b')); if (hasCountOption()) options.addOption( OptionBuilder.withLongOpt("count").withDescription("number of messages to send (default 1)") .hasArg(true).withArgName("COUNT").create('c')); if (hasModeOption()) options.addOption(OptionBuilder.withLongOpt("acknowledge-mode") .withDescription("acknowledgement mode: AMO|ALO|EO (At Least Once, At Most Once, Exactly Once") .hasArg(true).withArgName("MODE").create('k')); if (hasSubjectOption()) options.addOption(OptionBuilder.withLongOpt("subject").withDescription("subject message property") .hasArg(true).withArgName("SUBJECT").create('s')); if (hasSingleLinkPerConnectionMode()) options.addOption(OptionBuilder.withLongOpt("single-link-per-connection") .withDescription("acknowledgement mode: AMO|ALO|EO (At Least Once, At Most Once, Exactly Once") .hasArg(false).create('Z')); if (hasFilterOption()) options.addOption(OptionBuilder.withLongOpt("filter") .withDescription("filter, e.g. exact-subject=hello; matching-subject=%.a.#").hasArg(true) .withArgName("<TYPE>=<VALUE>").create('F')); if (hasTxnOption()) { options.addOption("x", "txn", false, "use transactions"); options.addOption( OptionBuilder.withLongOpt("batch-size").withDescription("transaction batch size (default: 1)") .hasArg(true).withArgName("BATCH-SIZE").create('B')); options.addOption(OptionBuilder.withLongOpt("rollback-ratio") .withDescription("rollback ratio - must be between 0 and 1 (default: 0)").hasArg(true) .withArgName("RATIO").create('R')); } if (hasLinkDurableOption()) { options.addOption("d", "durable-link", false, "use a durable link"); } if (hasStdInOption()) options.addOption("i", "stdin", false, "read messages from stdin (one message per line)"); options.addOption( OptionBuilder.withLongOpt("trace").withDescription("trace logging specified categories: RAW, FRM") .hasArg(true).withArgName("TRACE").create('t')); if (hasSizeOption()) options.addOption( OptionBuilder.withLongOpt("message-size").withDescription("size to pad outgoing messages to") .hasArg(true).withArgName("SIZE").create('z')); if (hasResponseQueueOption()) options.addOption( OptionBuilder.withLongOpt("response-queue").withDescription("response queue to reply to") .hasArg(true).withArgName("RESPONSE_QUEUE").create('r')); if (hasLinkNameOption()) { options.addOption(OptionBuilder.withLongOpt("link").withDescription("link name").hasArg(true) .withArgName("LINK").create('l')); } if (hasWindowSizeOption()) { options.addOption(OptionBuilder.withLongOpt("window-size").withDescription("credit window size") .hasArg(true).withArgName("WINDOW-SIZE").create('W')); } CommandLine cmdLine = null; try { cmdLine = cmdLineParse.parse(options, args); } catch (ParseException e) { printUsage(options); System.exit(-1); } if (cmdLine.hasOption('h') || cmdLine.getArgList().isEmpty()) { printUsage(options); System.exit(0); } _host = cmdLine.getOptionValue('H', "0.0.0.0"); _remoteHost = cmdLine.getOptionValue('O', null); String portStr = cmdLine.getOptionValue('p', "5672"); String countStr = cmdLine.getOptionValue('c', "1"); _useSSL = cmdLine.hasOption('S'); if (hasWindowSizeOption()) { String windowSizeStr = cmdLine.getOptionValue('W', "100"); _windowSize = Integer.parseInt(windowSizeStr); } if (hasSubjectOption()) { _subject = cmdLine.getOptionValue('s'); } if (cmdLine.hasOption('u')) { _username = cmdLine.getOptionValue('u'); } if (cmdLine.hasOption('w')) { _password = cmdLine.getOptionValue('w'); } if (cmdLine.hasOption('F')) { _filter = cmdLine.getOptionValue('F'); } _port = Integer.parseInt(portStr); _containerName = cmdLine.getOptionValue('C'); if (hasBlockOption()) _block = cmdLine.hasOption('b'); if (hasLinkNameOption()) _linkName = cmdLine.getOptionValue('l'); if (hasLinkDurableOption()) _durableLink = cmdLine.hasOption('d'); if (hasCountOption()) _count = Integer.parseInt(countStr); if (hasStdInOption()) _useStdIn = cmdLine.hasOption('i'); if (hasSingleLinkPerConnectionMode()) _useMultipleConnections = cmdLine.hasOption('Z'); if (hasTxnOption()) { _useTran = cmdLine.hasOption('x'); _batchSize = Integer.parseInt(cmdLine.getOptionValue('B', "1")); _rollbackRatio = Double.parseDouble(cmdLine.getOptionValue('R', "0")); } if (hasModeOption()) { _mode = AcknowledgeMode.ALO; if (cmdLine.hasOption('k')) { _mode = AcknowledgeMode.valueOf(cmdLine.getOptionValue('k')); } } if (hasResponseQueueOption()) { _responseQueue = cmdLine.getOptionValue('r'); } _frameSize = Integer.parseInt(cmdLine.getOptionValue('f', "65536")); if (hasSizeOption()) { _messageSize = Integer.parseInt(cmdLine.getOptionValue('z', "-1")); } String categoriesList = cmdLine.getOptionValue('t'); String[] categories = categoriesList == null ? new String[0] : categoriesList.split("[, ]"); for (String cat : categories) { if (cat.equalsIgnoreCase("FRM")) { FRAME_LOGGER.setLevel(Level.FINE); Formatter formatter = new Formatter() { @Override public String format(final LogRecord record) { return "[" + record.getMillis() + " FRM]\t" + record.getMessage() + "\n"; } }; for (Handler handler : FRAME_LOGGER.getHandlers()) { FRAME_LOGGER.removeHandler(handler); } Handler handler = new ConsoleHandler(); handler.setLevel(Level.FINE); handler.setFormatter(formatter); FRAME_LOGGER.addHandler(handler); } else if (cat.equalsIgnoreCase("RAW")) { RAW_LOGGER.setLevel(Level.FINE); Formatter formatter = new Formatter() { @Override public String format(final LogRecord record) { return "[" + record.getMillis() + " RAW]\t" + record.getMessage() + "\n"; } }; for (Handler handler : RAW_LOGGER.getHandlers()) { RAW_LOGGER.removeHandler(handler); } Handler handler = new ConsoleHandler(); handler.setLevel(Level.FINE); handler.setFormatter(formatter); RAW_LOGGER.addHandler(handler); } } _args = cmdLine.getArgs(); }
From source file:org.apache.samza.tools.CommandLineHelper.java
public static Option createOption(String shortOpt, String longOpt, String argName, boolean required, String description) {/*from w w w .j ava 2s. c o m*/ OptionBuilder optionBuilder = OptionBuilder.withLongOpt(longOpt).withDescription(description) .isRequired(required); if (!StringUtils.isEmpty(argName)) { optionBuilder = optionBuilder.withArgName(argName).hasArg(); } return optionBuilder.create(shortOpt); }
From source file:org.apache.sqoop.shell.GrantPrivilegeFunction.java
@SuppressWarnings("static-access") public GrantPrivilegeFunction() { this.addOption(OptionBuilder.withLongOpt(Constants.OPT_RESOURCE_TYPE) .withDescription(resourceString(Constants.RES_PROMPT_RESOURCE_TYPE)).isRequired().hasArg() .create());// w w w .j av a 2 s . c o m this.addOption(OptionBuilder.withLongOpt(Constants.OPT_RESOURCE) .withDescription(resourceString(Constants.RES_PROMPT_RESOURCE)).isRequired().hasArg().create()); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_ACTION) .withDescription(resourceString(Constants.RES_PROMPT_ACTION)).isRequired().hasArg() .create(Constants.OPT_ACTION_CHAR)); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL)).isRequired().hasArg().create()); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL_TYPE) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL_TYPE)).isRequired().hasArg() .create()); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_WITH_GRANT) .withDescription(resourceString(Constants.RES_PROMPT_WITH_GRANT)) .create(Constants.OPT_WITH_GRANT_CHAR)); }
From source file:org.apache.sqoop.shell.GrantRoleFunction.java
@SuppressWarnings("static-access") public GrantRoleFunction() { this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL_TYPE) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL_TYPE)).isRequired().hasArgs() .create());// w w w .ja va 2 s. co m this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL)).isRequired().hasArgs().create()); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_ROLE) .withDescription(resourceString(Constants.RES_PROMPT_ROLE)).isRequired().hasArgs() .create(Constants.OPT_ROLE_CHAR)); }
From source file:org.apache.sqoop.shell.RevokePrivilegeFunction.java
@SuppressWarnings("static-access") public RevokePrivilegeFunction() { this.addOption(OptionBuilder.withLongOpt(Constants.OPT_RESOURCE_TYPE) .withDescription(resourceString(Constants.RES_PROMPT_RESOURCE_TYPE)).isRequired().hasArg() .create());// w w w . j a va2 s . c om this.addOption(OptionBuilder.withLongOpt(Constants.OPT_RESOURCE) .withDescription(resourceString(Constants.RES_PROMPT_RESOURCE)).isRequired().hasArg().create()); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_ACTION) .withDescription(resourceString(Constants.RES_PROMPT_ACTION)).isRequired().hasArg() .create(Constants.OPT_ACTION_CHAR)); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL)).isRequired().hasArg().create()); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL_TYPE) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL_TYPE)).isRequired().hasArg() .create()); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_WITH_GRANT) .withDescription(resourceString(Constants.RES_PROMPT_WITH_GRANT)) .create(Constants.OPT_WITH_GRANT_CHAR)); }
From source file:org.apache.sqoop.shell.RevokeRoleFunction.java
@SuppressWarnings("static-access") public RevokeRoleFunction() { this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL_TYPE) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL_TYPE)).isRequired().hasArgs() .create());/* w ww. ja v a 2s . c o m*/ this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL)).isRequired().hasArgs().create()); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_ROLE) .withDescription(resourceString(Constants.RES_PROMPT_ROLE)).isRequired().hasArgs() .create(Constants.OPT_ROLE_CHAR)); }
From source file:org.apache.sqoop.shell.ShowPrincipalFunction.java
@SuppressWarnings("static-access") public ShowPrincipalFunction() { this.addOption(OptionBuilder.withLongOpt(Constants.OPT_ROLE) .withDescription(resourceString(Constants.RES_PROMPT_ROLE)).hasArg().isRequired() .create(Constants.OPT_ROLE_CHAR)); }