List of usage examples for org.apache.commons.cli OptionBuilder withLongOpt
public static OptionBuilder withLongOpt(String newLongopt)
From source file:com.linkedin.helix.mock.storage.DummyProcess.java
@SuppressWarnings("static-access") synchronized private static Options constructCommandLineOptions() { Option helpOption = OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info") .create();//from w ww. jav a 2 s. co m Option clusterOption = OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create(); clusterOption.setArgs(1); clusterOption.setRequired(true); clusterOption.setArgName("Cluster name (Required)"); Option hostOption = OptionBuilder.withLongOpt(hostAddress).withDescription("Provide host name").create(); hostOption.setArgs(1); hostOption.setRequired(true); hostOption.setArgName("Host name (Required)"); Option portOption = OptionBuilder.withLongOpt(hostPort).withDescription("Provide host port").create(); portOption.setArgs(1); portOption.setRequired(true); portOption.setArgName("Host port (Required)"); Option cmTypeOption = OptionBuilder.withLongOpt(helixManagerType) .withDescription("Provide cluster manager type (e.g. 'zk', 'static-file', or 'dynamic-file'") .create(); cmTypeOption.setArgs(1); cmTypeOption.setRequired(true); cmTypeOption.setArgName("Clsuter manager type (e.g. 'zk', 'static-file', or 'dynamic-file') (Required)"); // add an option group including either --zkSvr or --clusterViewFile Option fileOption = OptionBuilder.withLongOpt(clusterViewFile) .withDescription("Provide a cluster-view file for static-file based cluster manager").create(); fileOption.setArgs(1); fileOption.setRequired(true); fileOption.setArgName("Cluster-view file (Required for static-file based cluster manager)"); Option zkServerOption = OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address") .create(); zkServerOption.setArgs(1); zkServerOption.setRequired(true); zkServerOption.setArgName("ZookeeperServerAddress(Required for zk-based cluster manager)"); // Option rootNsOption = OptionBuilder.withLongOpt(rootNamespace) // .withDescription("Provide root namespace for dynamic-file based cluster manager").create(); // rootNsOption.setArgs(1); // rootNsOption.setRequired(true); // rootNsOption.setArgName("Root namespace (Required for dynamic-file based cluster manager)"); Option transDelayOption = OptionBuilder.withLongOpt(transDelay).withDescription("Provide state trans delay") .create(); transDelayOption.setArgs(1); transDelayOption.setRequired(false); transDelayOption.setArgName("Delay time in state transition, in MS"); OptionGroup optionGroup = new OptionGroup(); optionGroup.addOption(zkServerOption); optionGroup.addOption(fileOption); // optionGroup.addOption(rootNsOption); Options options = new Options(); options.addOption(helpOption); options.addOption(clusterOption); options.addOption(hostOption); options.addOption(portOption); options.addOption(transDelayOption); options.addOption(cmTypeOption); options.addOptionGroup(optionGroup); return options; }
From source file:edu.usc.ir.geo.gazetteer.GeoNameResolver.java
public static void main(String[] args) throws Exception { Option buildOpt = OptionBuilder.withArgName("gazetteer file").hasArg().withLongOpt("build") .withDescription("The Path to the Geonames allCountries.txt").create('b'); Option searchOpt = OptionBuilder.withArgName("set of location names").withLongOpt("search").hasArgs() .withDescription("Location names to search the Gazetteer for").create('s'); Option indexOpt = OptionBuilder.withArgName("directoryPath").withLongOpt("index").hasArgs() .withDescription("The path to the Lucene index directory to either create or read").create('i'); Option helpOpt = OptionBuilder.withLongOpt("help").withDescription("Print this message.").create('h'); Option resultCountOpt = OptionBuilder.withArgName("number of results").withLongOpt("count").hasArgs() .withDescription("Number of best results to be returned for one location").withType(Integer.class) .create('c'); Option serverOption = OptionBuilder.withArgName("Launch Server").withLongOpt("server") .withDescription("Launches Geo Gazetteer Service").create("server"); Option jsonOption = OptionBuilder.withArgName("outputs json").withLongOpt(JSON_OPT) .withDescription("Formats output in well defined json structure").create(JSON_OPT); String indexPath = null;//from w w w.ja va 2s.co m String gazetteerPath = null; Options options = new Options(); options.addOption(buildOpt); options.addOption(searchOpt); options.addOption(indexOpt); options.addOption(helpOpt); options.addOption(resultCountOpt); options.addOption(serverOption); options.addOption(jsonOption); // create the parser CommandLineParser parser = new DefaultParser(); GeoNameResolver resolver = new GeoNameResolver(); try { // parse the command line arguments CommandLine line = parser.parse(options, args); if (line.hasOption("index")) { indexPath = line.getOptionValue("index"); } if (line.hasOption("build")) { gazetteerPath = line.getOptionValue("build"); } if (line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("lucene-geo-gazetteer", options); System.exit(1); } if (indexPath != null && gazetteerPath != null) { LOG.info("Building Lucene index at path: [" + indexPath + "] with geoNames.org file: [" + gazetteerPath + "]"); resolver.buildIndex(gazetteerPath, indexPath); } if (line.hasOption("search")) { List<String> geoTerms = new ArrayList<String>(Arrays.asList(line.getOptionValues("search"))); String countStr = line.getOptionValue("count", "1"); int count = 1; if (countStr.matches("\\d+")) count = Integer.parseInt(countStr); Map<String, List<Location>> resolved = resolver.searchGeoName(indexPath, geoTerms, count); if (line.hasOption(JSON_OPT)) { writeResultJson(resolved, System.out); } else { writeResult(resolved, System.out); } } else if (line.hasOption("server")) { if (indexPath == null) { System.err.println("Index path is required"); System.exit(-2); } //TODO: get port from CLI args int port = 8765; Launcher.launchService(port, indexPath); } else { System.err.println("Sub command not recognised"); System.exit(-1); } } catch (ParseException exp) { // oops, something went wrong System.err.println("Parsing failed. Reason: " + exp.getMessage()); } }
From source file:com.cc.apptroy.baksmali.main.java
@SuppressWarnings("AccessStaticViaInstance") private static void buildOptions() { Option versionOption = OptionBuilder.withLongOpt("version").withDescription("prints the version then exits") .create("v"); Option helpOption = OptionBuilder.withLongOpt("help") .withDescription("prints the help message then exits. Specify twice for debug options").create("?"); Option outputDirOption = OptionBuilder.withLongOpt("output") .withDescription("the directory where the disassembled files will be placed. The default is out") .hasArg().withArgName("DIR").create("o"); Option noParameterRegistersOption = OptionBuilder.withLongOpt("no-parameter-registers").withDescription( "use the v<n> syntax instead of the p<n> syntax for registers mapped to method " + "parameters") .create("p"); Option deodexerantOption = OptionBuilder.withLongOpt("deodex").withDescription( "deodex the given odex file. This option is ignored if the input file is not an " + "odex file") .create("x"); Option experimentalOption = OptionBuilder.withLongOpt("experimental").withDescription( "enable experimental opcodes to be disassembled, even if they aren't necessarily supported in the Android runtime yet") .create("X"); Option useLocalsOption = OptionBuilder.withLongOpt("use-locals") .withDescription("output the .locals directive with the number of non-parameter registers, rather" + " than the .register directive with the total number of register") .create("l"); Option sequentialLabelsOption = OptionBuilder.withLongOpt("sequential-labels") .withDescription(//ww w . j a va 2 s. c o m "create label names using a sequential numbering scheme per label type, rather than " + "using the bytecode address") .create("s"); Option noDebugInfoOption = OptionBuilder.withLongOpt("no-debug-info") .withDescription("don't write out debug info (.local, .param, .line, etc.)").create("b"); Option registerInfoOption = OptionBuilder.withLongOpt("register-info").hasOptionalArgs() .withArgName("REGISTER_INFO_TYPES").withValueSeparator(',') .withDescription("print the specificed type(s) of register information for each instruction. " + "\"ARGS,DEST\" is the default if no types are specified.\nValid values are:\nALL: all " + "pre- and post-instruction registers.\nALLPRE: all pre-instruction registers\nALLPOST: all " + "post-instruction registers\nARGS: any pre-instruction registers used as arguments to the " + "instruction\nDEST: the post-instruction destination register, if any\nMERGE: Any " + "pre-instruction register has been merged from more than 1 different post-instruction " + "register from its predecessors\nFULLMERGE: For each register that would be printed by " + "MERGE, also show the incoming register types that were merged") .create("r"); Option classPathOption = OptionBuilder.withLongOpt("bootclasspath") .withDescription("the bootclasspath jars to use, for analysis. Defaults to " + "core.jar:ext.jar:framework.jar:android.policy.jar:services.jar. If the value begins with a " + ":, it will be appended to the default bootclasspath instead of replacing it") .hasOptionalArg().withArgName("BOOTCLASSPATH").create("c"); Option classPathDirOption = OptionBuilder.withLongOpt("bootclasspath-dir").withDescription( "the base folder to look for the bootclasspath files in. Defaults to the current " + "directory") .hasArg().withArgName("DIR").create("d"); Option codeOffsetOption = OptionBuilder.withLongOpt("code-offsets") .withDescription("add comments to the disassembly containing the code offset for each address") .create("f"); Option noAccessorCommentsOption = OptionBuilder.withLongOpt("no-accessor-comments") .withDescription("don't output helper comments for synthetic accessors").create("m"); Option apiLevelOption = OptionBuilder.withLongOpt("api-level") .withDescription("The numeric api-level of the file being disassembled. If not " + "specified, it defaults to 15 (ICS).") .hasArg().withArgName("API_LEVEL").create("a"); Option jobsOption = OptionBuilder.withLongOpt("jobs") .withDescription("The number of threads to use. Defaults to the number of cores available, up to a " + "maximum of 6") .hasArg().withArgName("NUM_THREADS").create("j"); Option resourceIdFilesOption = OptionBuilder.withLongOpt("resource-id-files") .withDescription( "the resource ID files to use, for analysis. A colon-separated list of prefix=file " + "pairs. For example R=res/values/public.xml:" + "android.R=$ANDROID_HOME/platforms/android-19/data/res/values/public.xml") .hasArg().withArgName("FILES").create("i"); Option noImplicitReferencesOption = OptionBuilder.withLongOpt("implicit-references") .withDescription("Use implicit (type-less) method and field references").create("t"); Option checkPackagePrivateAccessOption = OptionBuilder.withLongOpt("check-package-private-access") .withDescription("When deodexing, use the package-private access check when calculating vtable " + "indexes. It should only be needed for 4.2.0 odexes. The functionality was reverted for " + "4.2.1.") .create("k"); Option dumpOption = OptionBuilder.withLongOpt("dump-to") .withDescription("dumps the given dex file into a single annotated dump file named FILE" + " (<dexfile>.dump by default), along with the normal disassembly") .hasOptionalArg().withArgName("FILE").create("D"); Option ignoreErrorsOption = OptionBuilder.withLongOpt("ignore-errors") .withDescription("ignores any non-fatal errors that occur while disassembling/deodexing," + " ignoring the class if needed, and continuing with the next class. The default" + " behavior is to stop disassembling and exit once an error is encountered") .create("I"); Option noDisassemblyOption = OptionBuilder.withLongOpt("no-disassembly") .withDescription("suppresses the output of the disassembly").create("N"); Option inlineTableOption = OptionBuilder.withLongOpt("inline-table") .withDescription("specify a file containing a custom inline method table to use for deodexing") .hasArg().withArgName("FILE").create("T"); Option dexEntryOption = OptionBuilder.withLongOpt("dex-file") .withDescription("looks for dex file named DEX_FILE, defaults to classes.dex") .withArgName("DEX_FILE").hasArg().create("e"); basicOptions.addOption(versionOption); basicOptions.addOption(helpOption); basicOptions.addOption(outputDirOption); basicOptions.addOption(noParameterRegistersOption); basicOptions.addOption(deodexerantOption); basicOptions.addOption(experimentalOption); basicOptions.addOption(useLocalsOption); basicOptions.addOption(sequentialLabelsOption); basicOptions.addOption(noDebugInfoOption); basicOptions.addOption(registerInfoOption); basicOptions.addOption(classPathOption); basicOptions.addOption(classPathDirOption); basicOptions.addOption(codeOffsetOption); basicOptions.addOption(noAccessorCommentsOption); basicOptions.addOption(apiLevelOption); basicOptions.addOption(jobsOption); basicOptions.addOption(resourceIdFilesOption); basicOptions.addOption(noImplicitReferencesOption); basicOptions.addOption(dexEntryOption); basicOptions.addOption(checkPackagePrivateAccessOption); debugOptions.addOption(dumpOption); debugOptions.addOption(ignoreErrorsOption); debugOptions.addOption(noDisassemblyOption); debugOptions.addOption(inlineTableOption); for (Object option : basicOptions.getOptions()) { options.addOption((Option) option); } for (Object option : debugOptions.getOptions()) { options.addOption((Option) option); } }
From source file:UartEchoServer.java
public static void main(String[] aArgs) { final Options options = new Options(); options.addOption(new Option(OPTION_HELP, "print this message")); OptionBuilder.withLongOpt(OPTION_PORT); OptionBuilder.withDescription("set port COMx"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg();/*from w ww .j a va 2s . c om*/ options.addOption(OptionBuilder.create()); OptionBuilder.withLongOpt(OPTION_BAUD); OptionBuilder.withDescription("set the baud rate"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withLongOpt(OPTION_DATA); OptionBuilder.withDescription("set the data bits [" + DATA_BITS_5 + "|" + DATA_BITS_6 + "|" + DATA_BITS_7 + "|" + DATA_BITS_8 + "]"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withLongOpt(OPTION_STOP); OptionBuilder.withDescription( "set the stop bits [" + STOP_BITS_1 + "|" + STOP_BITS_1_5 + "|" + STOP_BITS_2 + "]"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withLongOpt(OPTION_PARITY); OptionBuilder.withDescription("set the parity [" + PARITY_NONE + "|" + PARITY_EVEN + "|" + PARITY_ODD + "|" + PARITY_MARK + "|" + PARITY_SPACE + "]"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withLongOpt(OPTION_FLOW); OptionBuilder.withDescription("set the flow control [" + FLOWCONTROL_NONE + "|" + FLOWCONTROL_RTSCTS + "|" + FLOWCONTROL_XONXOFF + "]"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); final CommandLineParser parser = new PosixParser(); try { // parse the command line arguments final CommandLine commandLine = parser.parse(options, aArgs); if (commandLine.hasOption(OPTION_HELP)) { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("UartEchoServer", options); } else { final UartEchoServer echoServer = new UartEchoServer(); echoServer.Construct(commandLine); } } catch (Exception e) { e.printStackTrace(); } }
From source file:RealignSAMFile.java
/** * Method providing the CLI for the main method, also parsing input parameters etc. * @param args// www. j a v a2s. c o m * @return */ private static RealignSAMFile addCLIInterface(String[] args) { Options helpOptions = new Options(); helpOptions.addOption("h", "help", false, "show this help page"); Options options = new Options(); options.addOption("h", "help", false, "show this help page"); options.addOption(OptionBuilder.withLongOpt("input").withArgName("INPUT") .withDescription("the input SAM/BAM File").isRequired().hasArg().create("i")); options.addOption(OptionBuilder.withLongOpt("reference").withArgName("REFERENCE") .withDescription("the unmodified reference genome").isRequired().hasArg().create("r")); options.addOption(OptionBuilder.withLongOpt("elongation").withArgName("ELONGATION") .withDescription("the elongation factor [INT]").isRequired().hasArg().create("e")); options.addOption(OptionBuilder.withLongOpt("filterCircularReads").isRequired(false).withArgName("FILTER") .withDescription( "filter the reads that don't map to a circular identifier (true/false), default false") .hasArg().create("f")); options.addOption(OptionBuilder.withLongOpt("filterNonCircularSequences").isRequired(false) .withArgName("FILTERSEQUENCEIDS") .withDescription( "filter the sequence identifiers that are not circular identifiers (true/false), default false") .hasArg().create("x")); HelpFormatter helpformatter = new HelpFormatter(); CommandLineParser parser = new BasicParser(); try { CommandLine cmd = parser.parse(helpOptions, args); if (cmd.hasOption('h')) { helpformatter.printHelp(CLASS_NAME + "v" + VERSION, options); System.exit(0); } } catch (ParseException e1) { } String input = ""; String reference = ""; String tmpElongation = ""; Integer elongation = 0; String filter = ""; String filterSequenceIds = ""; try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption('i')) { input = cmd.getOptionValue('i'); } if (cmd.hasOption('e')) { tmpElongation = cmd.getOptionValue('e'); try { elongation = Integer.parseInt(tmpElongation); } catch (Exception e) { System.err.println("elongation not an Integer: " + tmpElongation); System.exit(0); } } if (cmd.hasOption('r')) { reference = cmd.getOptionValue('r'); } if (cmd.hasOption('f')) { filter = cmd.getOptionValue('f'); if (filter.equals("true") || filter.equals("TRUE") || filter.equals("1")) { filtered = true; } else { filtered = false; } } if (cmd.hasOption('x')) { filterSequenceIds = cmd.getOptionValue('x'); if (filterSequenceIds.equals("true") || filter.equals("TRUE") || filter.equals("1")) { filter_sequence_ids = true; } else { filter_sequence_ids = false; } } } catch (ParseException e) { helpformatter.printHelp(CLASS_NAME, options); System.err.println(e.getMessage()); System.exit(0); } RealignSAMFile rs = new RealignSAMFile(new File(input), new File(reference), elongation, filter); return rs; }
From source file:com.bluemarsh.jswat.console.Main.java
/** * Process the given command line arguments. * * @param args command line arguments. * @throws ParseException if argument parsing fails. *//*from w w w .ja v a 2 s. c om*/ private static void processArguments(String[] args) throws ParseException { Options options = new Options(); // Option: h/help OptionBuilder.withDescription(NbBundle.getMessage(Main.class, "MSG_Main_Option_help")); OptionBuilder.withLongOpt("help"); options.addOption(OptionBuilder.create("h")); // Option: attach <port> OptionBuilder.hasArg(); OptionBuilder.withArgName("port"); OptionBuilder.withDescription(NbBundle.getMessage(Main.class, "MSG_Main_Option_attach")); options.addOption(OptionBuilder.create("attach")); // Option: sourcepath <path> OptionBuilder.hasArg(); OptionBuilder.withArgName("path"); OptionBuilder.withDescription(NbBundle.getMessage(Main.class, "MSG_Main_Option_sourcepath")); options.addOption(OptionBuilder.create("sourcepath")); // Option: e/emacs OptionBuilder.withDescription(NbBundle.getMessage(Main.class, "MSG_Main_Option_jdb")); options.addOption(OptionBuilder.create("jdb")); // Parse the command line arguments. CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(options, args); // Interrogate the command line options. jdbEmulationMode = line.hasOption("jdb"); if (line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java com.bluemarsh.jswat.console.Main", options); System.exit(0); } if (line.hasOption("sourcepath")) { Session session = SessionProvider.getCurrentSession(); PathManager pm = PathProvider.getPathManager(session); String path = line.getOptionValue("sourcepath"); List<String> roots = Strings.stringToList(path, File.pathSeparator); pm.setSourcePath(roots); } if (line.hasOption("attach")) { final Session session = SessionProvider.getCurrentSession(); String port = line.getOptionValue("attach"); ConnectionFactory factory = ConnectionProvider.getConnectionFactory(); final JvmConnection connection; try { connection = factory.createSocket("localhost", port); // The actual connection may be made some time from now, // so set up a listener to be notified at that time. connection.addConnectionListener(new ConnectionListener() { @Override public void connected(ConnectionEvent event) { if (session.isConnected()) { // The user already connected to something else. JvmConnection c = event.getConnection(); c.getVM().dispose(); c.disconnect(); } else { session.connect(connection); } } }); connection.connect(); } catch (Exception e) { logger.log(Level.SEVERE, null, e); } } }
From source file:edu.kit.dama.transfer.client.impl.BaseUserClient.java
/** * Adds a new option to the default command line options. * * @param pOptionName The option and the short option character. * @param pDescription The plain text description of the option. * @param pArgCount The argument count.// w w w. jav a2 s .co m * @param pLongOption The long option string. * @param pMandatory TRUE = This option MUST be provided. */ public final void addOption(String pOptionName, String pDescription, int pArgCount, String pLongOption, boolean pMandatory) { if (pOptionName == null || pDescription == null) { throw new IllegalArgumentException("Neither pOptionName nor pDescription must be 'null'"); } OptionBuilder b = OptionBuilder.withLongOpt(pLongOption).withDescription(pDescription) .isRequired(pMandatory); if (pArgCount != 0) { if (pArgCount == 1) { b = b.hasArg(); } else { b = b.hasArgs(pArgCount); } } OPTIONS.addOption(b.create(pOptionName)); }
From source file:com.facebook.presto.accumulo.tools.TimestampCheckTask.java
@SuppressWarnings("static-access") @Override/*from w w w. j a v a2 s.co m*/ public Options getOptions() { Options opts = new Options(); opts.addOption(OptionBuilder.withLongOpt("authorizations").withDescription( "List of scan authorizations. Default is to get user authorizations for the user in the configuration.") .hasArgs().create(AUTHORIZATIONS_OPT)); opts.addOption(OptionBuilder.withLongOpt("schema").withDescription("Presto schema name").hasArg() .isRequired().create(SCHEMA_OPT)); opts.addOption(OptionBuilder.withLongOpt("table").withDescription("Presto table name").hasArg().isRequired() .create(TABLE_OPT)); opts.addOption(OptionBuilder.withLongOpt("start") .withDescription("Start timestamp in YYYY-MM-ddTHH:mm:ss.SSS+ZZZZ format").hasArg().isRequired() .create(START_OPT)); opts.addOption(OptionBuilder.withLongOpt("end") .withDescription("End timestamp in YYYY-MM-ddTHH:mm:ss.SSS+ZZZZ format").hasArg().isRequired() .create(END_OPT)); opts.addOption(OptionBuilder.withLongOpt("column").withDescription("Presto column name").hasArg() .isRequired().create(COLUMN_OPT)); return opts; }
From source file:com.indeed.imhotep.builder.tsv.TsvConverter.java
@SuppressWarnings("static-access") public static void main(String[] args) { final Options options; final CommandLineParser parser = new PosixParser(); final CommandLine cmd; options = new Options(); final Option idxLoc = OptionBuilder.withArgName("path").hasArg().withLongOpt("index-loc") .withDescription("").isRequired().create('i'); options.addOption(idxLoc);//w ww. ja v a2 s. c om final Option successLoc = OptionBuilder.withArgName("path").hasArg().withLongOpt("success-loc") .withDescription("").isRequired().create('s'); options.addOption(successLoc); final Option failureLoc = OptionBuilder.withArgName("path").hasArg().withLongOpt("failure-loc") .withDescription("").isRequired().create('f'); options.addOption(failureLoc); final Option dataLoc = OptionBuilder.withArgName("path").hasArg().withLongOpt("data-loc") .withDescription("Location to store the built indexes").isRequired().create('d'); options.addOption(dataLoc); final Option buildLoc = OptionBuilder.withArgName("path").hasArg().withLongOpt("build-loc") .withDescription("Local directory were the indexes are built").create('b'); options.addOption(buildLoc); final Option hdfsPrincipal = OptionBuilder.withArgName("name").hasArg().withLongOpt("hdfs-principal") .withDescription("HDFS principal (only when using HDFS)").create('p'); options.addOption(hdfsPrincipal); final Option hdfsKeytab = OptionBuilder.withArgName("file").hasArg().withLongOpt("hdfs-keytab") .withDescription("HDFS keytab file location (only when using HDFS)").create('k'); options.addOption(hdfsKeytab); final Option qaMode = OptionBuilder.withLongOpt("qa-mode").withDescription("Enable QA mode").create('q'); options.addOption(qaMode); try { cmd = parser.parse(options, args); } catch (ParseException exp) { System.out.println("Unexpected exception: " + exp.getMessage()); System.out.println("\n"); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("shardBuilder", options, true); return; } /* start up the shard builder */ final TsvConverter converter = new TsvConverter(); converter.init(cmd.getOptionValue('i'), cmd.getOptionValue('s'), cmd.getOptionValue('f'), cmd.getOptionValue('d'), cmd.getOptionValue('b'), cmd.getOptionValue('p'), cmd.getOptionValue('k'), cmd.hasOption('q')); converter.run(); }
From source file:com.altiscale.TcpProxy.HostPort.java
public static Options getCommandLineOptions() { Options options = new Options(); options.addOption("v", "verbose", false, "Verbose logging."); options.addOption("V", "version", false, "Print version number."); options.addOption(OptionBuilder.withLongOpt("port") .withDescription("Listening port for proxy clients. " + "Default listening port is " + ProxyConfiguration.defaultListeningPort + ".") .withArgName("PORT").withType(Number.class).hasArg().create('p')); options.addOption(OptionBuilder.withLongOpt("webstatus_port") .withDescription("Port for proxy status in html format: " + "http://localhost:" + ProxyConfiguration.defaultStatusPort + "/stats") .withArgName("STATUS_PORT").withType(Number.class).hasArg().create('w')); options.addOption(OptionBuilder.withLongOpt("servers").withArgName("HOST1:PORT1> <HOST2:PORT2") .withDescription("Server/servers for the proxy to connect to" + " in host:port format.").hasArgs() .withValueSeparator(' ').create('s')); options.addOption(OptionBuilder.withLongOpt("num_servers").withArgName("NUM_SERVERS") .withDescription("Number of servers to instatntiate.").hasArgs().create('n')); options.addOption(OptionBuilder.withLongOpt("load_balancer").withArgName("LOAD_BALANCER") .withDescription("Load balancing algorithm. Options: " + "RoundRobin, LeastUsed, UniformRandom.") .hasArg().create('b')); options.addOption(OptionBuilder.withLongOpt("ssh_binary").withArgName("SSH_BINARY") .withDescription("Optional path to use as ssh command. Default is ssh.").hasArg().create()); options.addOption(OptionBuilder.withLongOpt("jumphost_user").withArgName("USER") .withDescription("Username for ssh to jumphost.").hasArg().create('u')); options.addOption(OptionBuilder.withLongOpt("jumphost_credentials").withArgName("FILENAME") .withDescription("Filename for optional ssh credentials (ssh -i option).").hasArg().create('i')); options.addOption("C", "jumphost_compression", false, "Enable compression in ssh tunnels."); options.addOption(OptionBuilder.withLongOpt("jumphost_ciphers").withArgName("CIPHER_SPEC") .withDescription("Select ciphers for ssh tunnel encryption (ssh -c option).").hasArg().create('c')); options.addOption(OptionBuilder.withLongOpt("jumphost").withArgName("JUMPHOST:JH_PORT") .withDescription("Connect to servers via ssh tunnel to jumphost in jumphost:port format. " + "You still need to specify servers and their ports using --servers.") .hasArg().create('j')); options.addOption(OptionBuilder.withLongOpt("jumphost_server").withArgName("JHSERVER:JHS_PORT") .withDescription("Jumphost server behind the firewall to connect all servers using: " + "SSH_BINARY -i ~/.ssh/id_rsa -n -N -L PORT:JHSERVER:JHS_PORT -l USER " + "-p JH_PORT JUMPHOST") .hasArg().create('y')); options.addOption("o", "openInterfaces", false, "Open all interfaces for ssh tunnel using \\* as bind_address: " + "SSH_BINARY \\*:PORT:JHSERVER:JHS_PORT"); options.addOption(OptionBuilder.withLongOpt("help").create('h')); return options; }