/** * The next Option created will have a value that will be an instance * of <code>type</code>. * <p> * <b>Note:</b> this method is kept for binary compatibility and the * input type is supposed to be a {@link Class} object. * * @param newType the type of the Options argument value * @return the OptionBuilder instance * @deprecated since 1.3, use {@link #withType(Class)} instead */ @Deprecated public static OptionBuilder withType(Object newType) { return withType((Class<?>) newType); }
private static CommandLine parseArgs(String[] args) throws ParseException { Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("file") .withDescription("sequence file to read") .hasArg() .withArgName("<sequence_file_name>") .withType(String.class) .create("f")); options.addOption("o", "print_offsets_only", false, "whether to print only offsets " + "ignoring the message payload"); CommandLineParser parser = new GnuParser(); return parser.parse(options, args); }
private static CommandLine parseArgs(String[] args) throws ParseException { Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("command") .withDescription("command name. One of \"delete_committed_offsets\"") .hasArg() .withArgName("<command>") .withType(String.class) .create("c")); options.addOption(OptionBuilder.withLongOpt("topic") .withDescription("topic whose offset should be read") .hasArg() .withArgName("<topic>") .withType(String.class) .create("t")); options.addOption(OptionBuilder.withLongOpt("partition") .withDescription("kafka partition whose offset should be read") .hasArg() .withArgName("<partition>") .withType(Number.class) .create("p")); CommandLineParser parser = new GnuParser(); return parser.parse(options, args); }
.hasArg() .withArgName("<topic>") .withType(String.class) .create("t")); options.addOption(OptionBuilder.withLongOpt("start_offset") .hasArg() .withArgName("<offset>") .withType(Long.class) .create("s")); options.addOption(OptionBuilder.withLongOpt("end_offset") .hasArg() .withArgName("<offset>") .withType(Long.class) .create("e")); options.addOption(OptionBuilder.withLongOpt("messages") .hasArg() .withArgName("<num_messages>") .withType(Number.class) .create("m")); options.addOption("q", "sequence_offsets", false, "whether to verify that offsets " +
.hasArg() .withArgName("<topic>") .withType(String.class) .create("t")); options.addOption(OptionBuilder.withLongOpt("messages") .hasArg() .withArgName("<num_messages>") .withType(Number.class) .create("m")); options.addOption(OptionBuilder.withLongOpt("producers") .hasArg() .withArgName("<num_producer_threads>") .withType(Number.class) .create("p")); options.addOption(OptionBuilder.withLongOpt("type") .hasArg() .withArgName("<type>") .withType(String.class) .create("type")); options.addOption(OptionBuilder.withLongOpt("broker") .hasArg() .withArgName("<broker>") .withType(String.class) .create("broker")); options.addOption(OptionBuilder.withLongOpt("timeshift")
.create("program"); Option outscopt = OptionBuilder.withType(File.class).hasArg() .isRequired() .withDescription("schema file for output of reducer") .create("outschema"); Option outscmapopt = OptionBuilder.withType(File.class).hasArg() .withDescription("(optional) map output schema file, if different from outschema") .create("outschemamap"); Option redopt = OptionBuilder.withType(Integer.class).hasArg() .withDescription("(optional) number of reducers") .create("reduces"); Option cacheopt = OptionBuilder.withType(Boolean.class).hasArg() .withDescription("(optional) boolean indicating whether or not the exectuable should be distributed via distributed cache") .create("exec_cached");
@Test public void testGetParsedOptionValue() throws Exception { Options options = new Options(); options.addOption(OptionBuilder.hasArg().withType(Number.class).create("i")); options.addOption(OptionBuilder.hasArg().create("f")); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, new String[] { "-i", "123", "-f", "foo" }); assertEquals(123, ((Number) cmd.getParsedOptionValue("i")).intValue()); assertEquals("foo", cmd.getParsedOptionValue("f")); }
@Test public void testCompleteOption( ) { Option simple = OptionBuilder.withLongOpt( "simple option") .hasArg( ) .isRequired( ) .hasArgs( ) .withType( Float.class ) .withDescription( "this is a simple option" ) .create( 's' ); assertEquals( "s", simple.getOpt() ); assertEquals( "simple option", simple.getLongOpt() ); assertEquals( "this is a simple option", simple.getDescription() ); assertEquals( simple.getType(), Float.class ); assertTrue( simple.hasArg() ); assertTrue( simple.isRequired() ); assertTrue( simple.hasArgs() ); }
@Test public void testTwoCompleteOptions( ) { Option simple = OptionBuilder.withLongOpt( "simple option") .hasArg( ) .isRequired( ) .hasArgs( ) .withType( Float.class ) .withDescription( "this is a simple option" ) .create( 's' ); assertEquals( "s", simple.getOpt() ); assertEquals( "simple option", simple.getLongOpt() ); assertEquals( "this is a simple option", simple.getDescription() ); assertEquals( simple.getType(), Float.class ); assertTrue( simple.hasArg() ); assertTrue( simple.isRequired() ); assertTrue( simple.hasArgs() ); simple = OptionBuilder.withLongOpt( "dimple option") .hasArg( ) .withDescription( "this is a dimple option" ) .create( 'd' ); assertEquals( "d", simple.getOpt() ); assertEquals( "dimple option", simple.getLongOpt() ); assertEquals( "this is a dimple option", simple.getDescription() ); assertEquals( String.class, simple.getType() ); assertTrue( simple.hasArg() ); assertTrue( !simple.isRequired() ); assertTrue( !simple.hasArgs() ); }
/** * The next Option created will have a value that will be an instance * of <code>type</code>. * <p> * <b>Note:</b> this method is kept for binary compatibility and the * input type is supposed to be a {@link Class} object. * * @param newType the type of the Options argument value * @return the OptionBuilder instance * @deprecated since 1.3, use {@link #withType(Class)} instead */ @Deprecated public static OptionBuilder withType(Object newType) { return withType((Class<?>) newType); }
PESignerCLI() { options = new Options(); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_KEYSTORE).withArgName("FILE").withDescription("The keystore file, or the SunPKCS11 configuration file").withType(File.class).create('s')); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_STOREPASS).withArgName("PASSWORD").withDescription("The password to open the keystore").create()); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_STORETYPE).withArgName("TYPE").withDescription("The type of the keystore:\n- JKS: Java keystore (.jks files)\n- PKCS12: Standard PKCS#12 keystore (.p12 or .pfx files)\n- PKCS11: PKCS#11 hardware token\n").create()); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_ALIAS).withArgName("NAME").withDescription("The alias of the certificate used for signing in the keystore.").create('a')); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_KEYPASS).withArgName("PASSWORD").withDescription("The password of the private key. When using a keystore, this parameter can be omitted if the keystore shares the same password.").create()); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_KEYFILE).withArgName("FILE").withDescription("The file containing the private key. PEM and PVK files are supported. ").withType(File.class).create()); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_CERTFILE).withArgName("FILE").withDescription("The file containing the PKCS#7 certificate chain\n(.p7b or .spc files).").withType(File.class).create('c')); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_ALG).withArgName("ALGORITHM").withDescription("The digest algorithm (SHA-1, SHA-256, SHA-384 or SHA-512)").create('d')); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_TSAURL).withArgName("URL").withDescription("The URL of the timestamping authority.").create('t')); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_TSMODE).withArgName("MODE").withDescription("The timestamping mode (RFC3161 or Authenticode)").create('m')); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_TSRETRIES).withArgName("NUMBER").withDescription("The number of retries for timestamping").create('r')); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_TSRETRY_WAIT).withArgName("SECONDS").withDescription("The number of seconds to wait between timestamping retries").create('w')); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_NAME).withArgName("NAME").withDescription("The name of the application").create('n')); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_URL).withArgName("URL").withDescription("The URL of the application").create('u')); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_PROXY_URL).withArgName("URL").withDescription("The URL of the HTTP proxy").create()); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_PROXY_USER).withArgName("NAME").withDescription("The user for the HTTP proxy. If an user is needed.").create()); options.addOption(OptionBuilder.hasArg().withLongOpt(PARAM_PROXY_PASS).withArgName("PASSWORD").withDescription("The password for the HTTP proxy user. If an user is needed.").create()); options.addOption(OptionBuilder.withLongOpt(PARAM_REPLACE).withDescription("Tells if previous signatures should be replaced.").create()); options.addOption(OptionBuilder.withLongOpt("help").withDescription("Print the help").create('h')); }
public AddFind() { super("add", "a"); OptionBuilder.withArgName("outputDir"); OptionBuilder.withLongOpt("output"); OptionBuilder.hasArg(); OptionBuilder.withDescription("override default download directory"); OptionBuilder.withType(File.class); getOptions().addOption( OptionBuilder.create('o') ); getOptions().addOption("r", "recurse", false, "recurse sub-directories."); getOptions().addOption("f", "find", false, "only find files, don't add."); getOptions().addOption("h", "help", false, "display help about this command"); getOptions().addOption("l", "list", false, "list previous find results"); }
private static Options getOptions() { Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("host").isRequired().hasArg() .withDescription("PinLater server hostname").create()); options.addOption(OptionBuilder.withLongOpt("port").isRequired().hasArg() .withType(Number.class).withDescription("PinLater server port").create()); options.addOption(OptionBuilder.withLongOpt("mode").isRequired().hasArg() .withDescription("Mode: create, enqueue, dequeue, check_dequeue, lookup, " + "get_job_count, get_queue_names").create()); options.addOption(OptionBuilder.withLongOpt("queue").hasArg() .withDescription("Queue name").create()); options.addOption(OptionBuilder.withLongOpt("concurrency").hasArg() .withDescription("Query issue concurrency").create()); options.addOption(OptionBuilder.withLongOpt("batch_size").hasArg() .withDescription("Query batch size").create()); options.addOption(OptionBuilder.withLongOpt("num_queries").hasArg() .withDescription("How many enqueue/dequeue queries to issue, -1 for unlimited").create()); options.addOption(OptionBuilder.withLongOpt("dequeue_success_percent").hasArg() .withDescription("Dequeue success percent to use").create()); options.addOption(OptionBuilder.withLongOpt("job_descriptor").hasArg() .withDescription("Job descriptor to lookup").create()); options.addOption(OptionBuilder.withLongOpt("priority").hasArg() .withDescription("Job priority for enqueue").create()); options.addOption(OptionBuilder.withLongOpt("job_state").hasArg() .withDescription("Job state to search for").create()); options.addOption(OptionBuilder.withLongOpt("count_future_jobs").hasArg() .withDescription("Count future jobs instead of current jobs").create()); return options; }
result.addOption(OptionBuilder.hasArg().withLongOpt(OPTIMIZATION_LEVEL_OPTION).withType(Number.class).withDescription("[deprecated] -O0, -O1, -O2; Set the parser's optimization level. The lower the number, the less nodes it will create in the tree. This could matter for debugging, or if you want to access the individual nodes in the tree.").create('O')); result.addOption(OptionBuilder.withLongOpt(LINE_NUMBERS_OPTION).hasArg().withDescription("[deprecated] --line-numbers=TYPE Outputs filename and line numbers. TYPE can be either 'comments', which will output the debug info within comments, 'mediaquery' that will output the information within a fake media query which is compatible with the SASS format, and 'all' which will do both.").create());
.withDescription("Number of best results to be returned for one location").withType(Integer.class) .create('c');
.create("program"); Option outscopt = OptionBuilder.withType(File.class).hasArg() .isRequired() .withDescription("schema file for output of reducer") .create("outschema"); Option outscmapopt = OptionBuilder.withType(File.class).hasArg() .withDescription("(optional) map output schema file, if different from outschema") .create("outschemamap"); Option redopt = OptionBuilder.withType(Integer.class).hasArg() .withDescription("(optional) number of reducers") .create("reduces"); Option cacheopt = OptionBuilder.withType(Boolean.class).hasArg() .withDescription("(optional) boolean indicating whether or not the exectuable should be distributed via distributed cache") .create("exec_cached");