Java Code Examples for org.apache.commons.cli.OptionBuilder#hasArgs()
The following examples show how to use
org.apache.commons.cli.OptionBuilder#hasArgs() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OfflineEditsViewer.java From hadoop with Apache License 2.0 | 6 votes |
/** * Build command-line options and descriptions * * @return command line options */ public static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("outputFilename"); options.addOption(OptionBuilder.create("o")); OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFilename"); options.addOption(OptionBuilder.create("i")); options.addOption("p", "processor", true, ""); options.addOption("v", "verbose", false, ""); options.addOption("f", "fix-txids", false, ""); options.addOption("r", "recover", false, ""); options.addOption("h", "help", false, ""); return options; }
Example 2
Source File: OfflineImageViewer.java From hadoop with Apache License 2.0 | 6 votes |
/** * Build command-line options and descriptions */ public static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("outputFile"); options.addOption(OptionBuilder.create("o")); OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFile"); options.addOption(OptionBuilder.create("i")); options.addOption("p", "processor", true, ""); options.addOption("h", "help", false, ""); options.addOption("skipBlocks", false, ""); options.addOption("printToScreen", false, ""); options.addOption("delimiter", true, ""); return options; }
Example 3
Source File: OfflineImageViewerPB.java From hadoop with Apache License 2.0 | 6 votes |
/** * Build command-line options and descriptions */ private static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFile"); options.addOption(OptionBuilder.create("i")); options.addOption("o", "outputFile", true, ""); options.addOption("p", "processor", true, ""); options.addOption("h", "help", false, ""); options.addOption("maxSize", true, ""); options.addOption("step", true, ""); options.addOption("addr", true, ""); options.addOption("delimiter", true, ""); options.addOption("t", "temp", true, ""); return options; }
Example 4
Source File: OfflineEditsViewer.java From big-c with Apache License 2.0 | 6 votes |
/** * Build command-line options and descriptions * * @return command line options */ public static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("outputFilename"); options.addOption(OptionBuilder.create("o")); OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFilename"); options.addOption(OptionBuilder.create("i")); options.addOption("p", "processor", true, ""); options.addOption("v", "verbose", false, ""); options.addOption("f", "fix-txids", false, ""); options.addOption("r", "recover", false, ""); options.addOption("h", "help", false, ""); return options; }
Example 5
Source File: OfflineImageViewer.java From big-c with Apache License 2.0 | 6 votes |
/** * Build command-line options and descriptions */ public static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("outputFile"); options.addOption(OptionBuilder.create("o")); OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFile"); options.addOption(OptionBuilder.create("i")); options.addOption("p", "processor", true, ""); options.addOption("h", "help", false, ""); options.addOption("skipBlocks", false, ""); options.addOption("printToScreen", false, ""); options.addOption("delimiter", true, ""); return options; }
Example 6
Source File: OfflineImageViewerPB.java From big-c with Apache License 2.0 | 6 votes |
/** * Build command-line options and descriptions */ private static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFile"); options.addOption(OptionBuilder.create("i")); options.addOption("o", "outputFile", true, ""); options.addOption("p", "processor", true, ""); options.addOption("h", "help", false, ""); options.addOption("maxSize", true, ""); options.addOption("step", true, ""); options.addOption("addr", true, ""); options.addOption("delimiter", true, ""); options.addOption("t", "temp", true, ""); return options; }
Example 7
Source File: OfflineEditsViewer.java From RDFS with Apache License 2.0 | 6 votes |
/** * Build command-line options and descriptions * * @return command line options */ public static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("outputFilename"); options.addOption(OptionBuilder.create("o")); OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFilename"); options.addOption(OptionBuilder.create("i")); options.addOption("p", "processor", true, ""); options.addOption("v", "verbose", false, ""); options.addOption("h", "help", false, ""); return options; }
Example 8
Source File: OfflineImageViewer.java From RDFS with Apache License 2.0 | 6 votes |
/** * Build command-line options and descriptions */ public static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("outputFile"); options.addOption(OptionBuilder.create("o")); OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFile"); options.addOption(OptionBuilder.create("i")); options.addOption("p", "processor", true, ""); options.addOption("h", "help", false, ""); options.addOption("skipBlocks", false, ""); options.addOption("printToScreen", false, ""); options.addOption("delimiter", true, ""); return options; }
Example 9
Source File: CliOption.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
Option toCliOption() { OptionBuilder.withArgName(fArgumentName); // Number of arguments if (fMaxArguments == 0) { // No arguments OptionBuilder.hasArg(false); } else if (fMaxArguments == 1) { // 1 argument, optional or mandatory if (fMinArguments == 0) { OptionBuilder.hasOptionalArg(); } else { OptionBuilder.hasArg(); } } else if (fMaxArguments < Integer.MAX_VALUE) { // Many arguments, optional or mandatory if (fMinArguments == 0) { OptionBuilder.hasOptionalArgs(fMaxArguments); } else { OptionBuilder.hasArgs(fMaxArguments); } } else { // Unbounded number of optional or mandatory arguments if (fMinArguments == 0) { OptionBuilder.hasOptionalArgs(); } else { OptionBuilder.hasArgs(); } } if (fLongOption != null) { OptionBuilder.withLongOpt(fLongOption); } if (fDescription != null) { OptionBuilder.withDescription(fDescription); } return Objects.requireNonNull(OptionBuilder.create(fShortOption)); }
Example 10
Source File: ResolveUrls.java From nutch-htmlunit with Apache License 2.0 | 4 votes |
/** * Runs the resolve urls tool. */ public static void main(String[] args) { Options options = new Options(); OptionBuilder.withArgName("help"); OptionBuilder.withDescription("show this help message"); Option helpOpts = OptionBuilder.create("help"); options.addOption(helpOpts); OptionBuilder.withArgName("urls"); OptionBuilder.hasArg(); OptionBuilder.withDescription("the urls file to check"); Option urlOpts = OptionBuilder.create("urls"); options.addOption(urlOpts); OptionBuilder.withArgName("numThreads"); OptionBuilder.hasArgs(); OptionBuilder.withDescription("the number of threads to use"); Option numThreadOpts = OptionBuilder.create("numThreads"); options.addOption(numThreadOpts); CommandLineParser parser = new GnuParser(); try { // parse out common line arguments CommandLine line = parser.parse(options, args); if (line.hasOption("help") || !line.hasOption("urls")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("ResolveUrls", options); return; } // get the urls and the number of threads and start the resolver String urls = line.getOptionValue("urls"); int numThreads = 100; String numThreadsStr = line.getOptionValue("numThreads"); if (numThreadsStr != null) { numThreads = Integer.parseInt(numThreadsStr); } ResolveUrls resolve = new ResolveUrls(urls, numThreads); resolve.resolveUrls(); } catch (Exception e) { LOG.error("ResolveUrls: " + StringUtils.stringifyException(e)); } }
Example 11
Source File: WebGraph.java From nutch-htmlunit with Apache License 2.0 | 4 votes |
/** * Parses command link arguments and runs the WebGraph jobs. */ public int run(String[] args) throws Exception { Options options = new Options(); OptionBuilder.withArgName("help"); OptionBuilder.withDescription("show this help message"); Option helpOpts = OptionBuilder.create("help"); options.addOption(helpOpts); OptionBuilder.withArgName("webgraphdb"); OptionBuilder.hasArg(); OptionBuilder.withDescription("the web graph database to use"); Option webGraphDbOpts = OptionBuilder.create("webgraphdb"); options.addOption(webGraphDbOpts); OptionBuilder.withArgName("segment"); OptionBuilder.hasArgs(); OptionBuilder.withDescription("the segment(s) to use"); Option segOpts = OptionBuilder.create("segment"); options.addOption(segOpts); OptionBuilder.withArgName("segmentDir"); OptionBuilder.hasArgs(); OptionBuilder.withDescription("the segment directory to use"); Option segDirOpts = OptionBuilder.create("segmentDir"); options.addOption(segDirOpts); OptionBuilder.withArgName("normalize"); OptionBuilder.withDescription("whether to use URLNormalizers on the URL's in the segment"); Option normalizeOpts = OptionBuilder.create("normalize"); options.addOption(normalizeOpts); OptionBuilder.withArgName("filter"); OptionBuilder.withDescription("whether to use URLFilters on the URL's in the segment"); Option filterOpts = OptionBuilder.create("filter"); options.addOption(filterOpts); CommandLineParser parser = new GnuParser(); try { CommandLine line = parser.parse(options, args); if (line.hasOption("help") || !line.hasOption("webgraphdb") || (!line.hasOption("segment") && !line.hasOption("segmentDir"))) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("WebGraph", options); return -1; } String webGraphDb = line.getOptionValue("webgraphdb"); Path[] segPaths = null; // Handle segment option if (line.hasOption("segment")) { String[] segments = line.getOptionValues("segment"); segPaths = new Path[segments.length]; for (int i = 0; i < segments.length; i++) { segPaths[i] = new Path(segments[i]); } } // Handle segmentDir option if (line.hasOption("segmentDir")) { Path dir = new Path(line.getOptionValue("segmentDir")); FileSystem fs = dir.getFileSystem(getConf()); FileStatus[] fstats = fs.listStatus(dir, HadoopFSUtil.getPassDirectoriesFilter(fs)); segPaths = HadoopFSUtil.getPaths(fstats); } boolean normalize = false; if (line.hasOption("normalize")) { normalize = true; } boolean filter = false; if (line.hasOption("filter")) { filter = true; } createWebGraph(new Path(webGraphDb), segPaths, normalize, filter); return 0; } catch (Exception e) { LOG.error("WebGraph: " + StringUtils.stringifyException(e)); return -2; } }