List of usage examples for org.apache.commons.cli Option Option
public Option(String opt, boolean hasArg, String description) throws IllegalArgumentException
From source file:edu.vt.middleware.crypt.signature.SignatureCli.java
/** {@inheritDoc} */ protected void initOptions() { super.initOptions(); final Option alg = new Option(OPT_ALG, true, "signature algorithm; either DSA or RSA"); alg.setArgName("name"); alg.setOptionalArg(false);/*from w w w . j a v a 2 s . c o m*/ final Option key = new Option(OPT_KEY, true, "DER-encoded PKCS#8 private key for signing or " + "X.509 cert/public key for verification"); key.setArgName("filepath"); key.setOptionalArg(false); final Option infile = new Option(OPT_INFILE, true, "file to sign/verify; defaults to STDIN"); infile.setArgName("filepath"); infile.setOptionalArg(false); final Option digest = new Option(OPT_DIGEST, true, "message digest algorithm used to produce encoded message to sign"); digest.setArgName("algname"); digest.setOptionalArg(false); final Option encoding = new Option(OPT_ENCODING, true, "signature encoding format, either base64 or hex"); encoding.setArgName("format"); encoding.setOptionalArg(false); final Option verify = new Option(OPT_VERIFY, true, "verify signature in given file; " + "signature encoding determined by -encoding option"); encoding.setArgName("sigfilepath"); encoding.setOptionalArg(false); options.addOption(alg); options.addOption(key); options.addOption(infile); options.addOption(digest); options.addOption(encoding); options.addOption(verify); options.addOption(new Option(OPT_SIGN, "perform sign operation")); }
From source file:com.aliyun.openservices.odps.console.pub.ShowInstanceCommand.java
static Options initOptions() { Options opts = new Options(); Option project_name = new Option("p", true, "project name"); Option limit_number = new Option("limit", true, "show limit"); project_name.setRequired(false);// www. j av a2 s . co m limit_number.setRequired(false); opts.addOption(project_name); opts.addOption(limit_number); return opts; }
From source file:com.mebigfatguy.roomstore.RoomStore.java
private static Options createOptions() { Options options = new Options(); Option option = new Option(NICK_NAME, true, "nickname to use to access irc channels"); option.setRequired(true);/* w ww.j av a 2 s . com*/ options.addOption(option); option = new Option(IRCSERVER, true, "irc server url"); option.setRequired(true); options.addOption(option); option = new Option(CHANNELS, true, "space separated list of channels to connect to"); option.setRequired(true); option.setArgs(100); options.addOption(option); option = new Option(ENDPOINTS, true, "space separated list of cassandra server server/ports"); option.setOptionalArg(true); option.setRequired(false); option.setArgs(100); options.addOption(option); option = new Option(RF, true, "replication factor[default=1]"); option.setRequired(false); options.addOption(option); return options; }
From source file:hrytsenko.csv.Args.java
private static Option newOption(String name, String description, boolean required) { Option option = new Option(name, true, description); option.setArgs(UNLIMITED_VALUES);//from ww w . ja v a 2s . com option.setRequired(required); return option; }
From source file:com.genentech.chemistry.tool.sdfAggregator.SDFAggregator.java
private static void processOptions(String[] args) { Option opt;//from w ww . j a v a 2s . c om options = new Options(); parser = new PosixParser(); opt = new Option("in", true, "Input file oe-supported Use .sdf to specify the file type."); opt.setRequired(true); options.addOption(opt); opt = new Option("out", true, "Output file oe-supported Use .sdf to specify the file type."); opt.setRequired(true); options.addOption(opt); opt = new Option("groupby", true, "Tags to group by (i.e. ClusterID, AssayName). Assumes tags are presorted (i.e. through SDFSorter). " + "Use multiple -groupby tags to group by more than one field."); opt.setRequired(false); options.addOption(opt); groups = new ArrayList<String>(); String funcListStr = getAggregationFunctionDescriptions(); opt = new Option("function", true, "Aggregator function:\n" + funcListStr); opt.setRequired(true); options.addOption(opt); options.addOption("outputmode", true, "[all|first(def)|last] output function results to all or only first/last entry."); /* * private static void processOptions (String[] args){ */ try { cl = parser.parse(options, args); } catch (Exception exp) { // catch (ParseException exp) { System.err.println(exp.getMessage()); exitWithHelp(options); } // TODO: Check files exist inFile = cl.getOptionValue("in"); outFile = cl.getOptionValue("out"); outputMode = OUTPUTMODE.FIRST; if (cl.hasOption("outputmode")) { String outModeStr = cl.getOptionValue("outputmode"); if (outModeStr.matches("(?i)all")) outputMode = OUTPUTMODE.ALL; else if (outModeStr.equalsIgnoreCase("last")) outputMode = OUTPUTMODE.LAST; } String[] grpByArr = cl.getOptionValues("groupby"); if (grpByArr != null) groups.addAll(Arrays.asList(grpByArr)); String[] funcstr = cl.getOptionValues("function"); aAgg = createAggregationFunction(funcstr); }
From source file:com.microsoft.azure.servicebus.samples.autoforward.AutoForward.java
public static int runApp(String[] args, Function<String, Integer> run) { try {//from w ww . j av a 2 s .com String connectionString = null; // parse connection string from command line Options options = new Options(); options.addOption(new Option("c", true, "Connection string")); CommandLineParser clp = new DefaultParser(); CommandLine cl = clp.parse(options, args); if (cl.getOptionValue("c") != null) { connectionString = cl.getOptionValue("c"); } // get overrides from the environment String env = System.getenv(SB_SAMPLES_CONNECTIONSTRING); if (env != null) { connectionString = env; } if (connectionString == null) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("run jar with", "", options, "", true); return 2; } return run.apply(connectionString); } catch (Exception e) { System.out.printf("%s", e.toString()); return 3; } }