List of usage examples for org.apache.commons.cli OptionBuilder withLongOpt
public static OptionBuilder withLongOpt(String newLongopt)
From source file:com.pinterest.secor.main.TestLogMessageProducerMain.java
private static CommandLine parseArgs(String[] args) throws ParseException { Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("topic").withDescription("topic to post to").hasArg() .withArgName("<topic>").withType(String.class).create("t")); options.addOption(/*www .j a v a 2 s . com*/ OptionBuilder.withLongOpt("messages").withDescription("number of messages per producer to post") .hasArg().withArgName("<num_messages>").withType(Number.class).create("m")); options.addOption(OptionBuilder.withLongOpt("producers").withDescription("number of producer threads") .hasArg().withArgName("<num_producer_threads>").withType(Number.class).create("p")); options.addOption(OptionBuilder.withLongOpt("type").withDescription("type of producer - [json, binary]") .hasArg().withArgName("<type>").withType(String.class).create("type")); options.addOption(OptionBuilder.withLongOpt("broker").withDescription("broker string, e.g. localhost:9092") .hasArg().withArgName("<broker>").withType(String.class).create("broker")); options.addOption(OptionBuilder.withLongOpt("timeshift") .withDescription( "message timestamp adjustment in seconds, it will be deducted" + " from current time") .hasArg().withArgName("<timeshift>").withType(Number.class).create("timeshift")); CommandLineParser parser = new GnuParser(); return parser.parse(options, args); }
From source file:com.pinterest.secor.main.LogFileVerifierMain.java
private static CommandLine parseArgs(String[] args) throws ParseException { Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("topic").withDescription("kafka topic name").hasArg() .withArgName("<topic>").withType(String.class).create("t")); options.addOption(OptionBuilder.withLongOpt("start_offset") .withDescription("offset identifying the first set of files to check").withArgName("<offset>") .withType(Long.class).create("s")); options.addOption(OptionBuilder.withLongOpt("end_offset") .withDescription("offset identifying the last set of files to check").withArgName("<offset>") .withType(Long.class).create("e")); options.addOption(OptionBuilder.withLongOpt("messages").withDescription("expected number of messages") .hasArg().withArgName("<num_messages>").withType(Number.class).create("m")); options.addOption("q", "sequence_offsets", false, "whether to verify that offsets " + "increase sequentially. Requires loading all offsets in a snapshot " + "to memory so use cautiously"); CommandLineParser parser = new GnuParser(); return parser.parse(options, args); }
From source file:com.comcast.oscar.cli.commands.TLVtoJSON.java
/** * Set option parameters for command TLV to JSON display * @return Option// w w w. j a v a 2 s.c om */ public static final Option OptionParameters() { OptionBuilder.withArgName("TLV"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("tlv2json"); OptionBuilder.withDescription( "View the JSON array of a TLV EX: 030101 (NetworkAccess: Type 3 Length 1 Value 1)."); return OptionBuilder.create("t2j"); }
From source file:com.pinterest.secor.main.ZookeeperClientMain.java
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); }
From source file:com.comcast.oscar.cli.commands.Input.java
/** * Set option parameters for command Input * @return Option// w w w . ja v a 2 s .c o m */ public static final Option OptionParameters() { OptionBuilder.withArgName("filename"); OptionBuilder.hasArgs(1); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("input"); OptionBuilder.withDescription("File to analyze and/or compile/decompile."); return OptionBuilder.create("i"); }
From source file:com.comcast.oscar.cli.commands.JSONtoTLV.java
/** * Set option parameters for command JSON to TLV display * @return Option// w w w . j av a2 s.c om */ public static final Option OptionParameters() { OptionBuilder.withArgName("filename"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("json2tlv"); OptionBuilder.withDescription("View the TLV number of a JSON array within the file."); return OptionBuilder.create("j2t"); }
From source file:edu.usc.leqa.Main.java
/** * Parses the inputs./* w w w . j ava 2 s .c o m*/ * * @param args the args */ @SuppressWarnings("static-access") public static void parseInputs(String[] args) { Options options = new Options(); options.addOption( OptionBuilder.withLongOpt("input").withDescription("QASM/TFC input file (QASM is preferred)") .isRequired().hasArg().withArgName("file").create("i")); options.addOption(OptionBuilder.withLongOpt("fabric").withDescription("Fabric specification file") .isRequired().hasArg().withArgName("file").create("f")); options.addOption(OptionBuilder.withLongOpt("technology").withDescription("Technology file").isRequired() .hasArg().withArgName("file").create("t")); options.addOption(OptionBuilder.withLongOpt("speed").withDescription("Qubit movement speed").isRequired() .hasArg().withArgName("num").create("s")); options.addOption(OptionBuilder.withLongOpt("skip").withDescription("Skip invocation of QSPR").create("j")); options.addOption(OptionBuilder.withLongOpt("verbose") .withDescription("Verbosely prints the quantum operations").create("v")); options.addOption(OptionBuilder.withLongOpt("debug").withDescription("Print debugging info").create("d")); options.addOption(OptionBuilder.withLongOpt("help").withDescription("Print this help menu").create("h")); CommandLineParser parser = new GnuParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println(e.getMessage()); // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(80); formatter.printHelp("leqa", "LEQA estimates the latency of a given QASM/TFC " + "mapped to a given PMD fabric.", options, "", true); System.exit(-1); } inputFileAddr = cmd.getOptionValue("input"); if (!new File(inputFileAddr).exists()) { System.err.println("Input file " + inputFileAddr + " does not exist."); System.exit(-1); } else if (!new File(inputFileAddr).setReadable(true)) { System.err.println("Input file " + inputFileAddr + " does not have read permission."); System.exit(-1); } fabricFileAddr = cmd.getOptionValue("fabric"); if (!new File(fabricFileAddr).exists()) { System.err.println("Fabric file " + fabricFileAddr + " does not exist."); System.exit(-1); } else if (!new File(fabricFileAddr).setReadable(true)) { System.err.println("Fabric file " + inputFileAddr + " does not have read permission."); System.exit(-1); } techFileAddr = cmd.getOptionValue("technology"); if (!new File(techFileAddr).exists()) { System.err.println("Technology file " + techFileAddr + " does not exist."); System.exit(-1); } else if (!new File(techFileAddr).setReadable(true)) { System.err.println("Technology file " + inputFileAddr + " does not have read permission."); System.exit(-1); } speed = Double.parseDouble(cmd.getOptionValue("speed")); if (cmd.hasOption("skip")) { RuntimeConfig.SKIP = true; } else { RuntimeConfig.SKIP = false; } if (cmd.hasOption("debug")) { RuntimeConfig.DEBUG = true; } else { RuntimeConfig.DEBUG = false; } if (cmd.hasOption("verbose")) { RuntimeConfig.VERBOSE = true; } else { RuntimeConfig.VERBOSE = false; } }
From source file:com.denimgroup.threadfix.cli.CommandLineParser.java
@SuppressWarnings("static-access") public static final Options getOptions() { Options options = new Options(); Option teams = OptionBuilder.withLongOpt("teams") .withDescription("Fetches a list of ThreadFix teams and applications.").create("t"); options.addOption(teams);//from w ww.ja va2s .c o m options.addOption(new Option("help", "Print this message")); Option set = OptionBuilder.withArgName("property> <value").withValueSeparator(' ').hasArgs(2) .withLongOpt("set") .withDescription("Set either the url (ThreadFix base url) or key (ThreadFix API key) properties") .create("s"); options.addOption(set); Option createTeam = OptionBuilder.withArgName("name").hasArg().withLongOpt("create-team") .withDescription("Creates a ThreadFix team and returns its JSON.").create("ct"); options.addOption(createTeam); Option createApp = OptionBuilder.withArgName("teamId> <name> <url").withValueSeparator(' ').hasArgs(3) .withLongOpt("create-app").withDescription("Creates a ThreadFix application and returns its JSON.") .create("ca"); options.addOption(createApp); Option createWaf = OptionBuilder.withArgName("name> <wafTypeName").withValueSeparator(' ').hasArgs(2) .withLongOpt("create-waf").withDescription("Creates a ThreadFix WAF and returns its JSON.") .create("cw"); options.addOption(createWaf); Option searchTeam = OptionBuilder.withArgName("property> <value").withValueSeparator(' ').hasArgs(2) .withLongOpt("search-team").withDescription("Searches for a ThreadFix team and returns its JSON.") .create("st"); options.addOption(searchTeam); Option searchWaf = OptionBuilder.withArgName("property> <value").withValueSeparator(' ').hasArgs(2) .withLongOpt("search-waf").withDescription("Searches for a ThreadFix WAF and returns its JSON.") .create("sw"); options.addOption(searchWaf); Option searchApp = OptionBuilder.withArgName("property> <value1> <value2").withValueSeparator(' ') .hasArgs(3).withLongOpt("search-app") .withDescription("Searches for a ThreadFix application and returns its JSON.").create("sa"); options.addOption(searchApp); Option upload = OptionBuilder.withArgName("appId> <file").withValueSeparator(' ').hasArgs(2) .withLongOpt("upload").withDescription("Uploads a scan to the specified application.").create("u"); options.addOption(upload); Option getRules = OptionBuilder.withArgName("wafId").hasArg().withLongOpt("rules") .withDescription("Gets WAF Rules and returns its JSON.").create("r"); options.addOption(getRules); return options; }
From source file:com.comcast.oscar.cli.commands.OID.java
/** * Set option parameters for command OID * @return Option/* www. ja v a2 s. co m*/ */ public static Option OptionParameters() { OptionBuilder.withArgName("[<OID>][<value>][<data type>]"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("OID"); OptionBuilder.withDescription("Insert this OID into a file when compiling. " + "Multiple OIDs can be inserted simultaneously (space delimited). " + "Applicable datatypes: " + BERService.getDataTypeStringList()); return OptionBuilder.create("O"); }
From source file:com.comcast.oscar.cli.commands.TFTPServer.java
/** * Set option parameters for command TFTP Server Address * @return Option/*from w w w.j a va2 s. com*/ */ public static final Option OptionParameters() { OptionBuilder.withArgName("v4/v6=<tftp address>"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("tftp"); OptionBuilder.withDescription("Add this TFTP server during file compilation. " + "For IPv4 use this format for the argument: v4=<server address>. " + "For IPv6 use this format for the argument: v6=<server address>. " + "Both address versions can be inserted simultaneously (space delimited)."); return OptionBuilder.create("T"); }