Options options = new Options(); options.addOption(input); options.addOption(output); HelpFormatter formatter = new HelpFormatter(); CommandLine cmd; cmd = parser.parse(options, args); } catch (ParseException e) { System.out.println(e.getMessage()); formatter.printHelp("utility-name", options); String inputFilePath = cmd.getOptionValue("input"); String outputFilePath = cmd.getOptionValue("output");
public static CommandLine parseCmdLine(final String appName, String[] args, Options options, CommandLineParser parser) { HelpFormatter hf = new HelpFormatter(); hf.setWidth(110); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); if (commandLine.hasOption('h')) { hf.printHelp(appName, options, true); return null; } } catch (ParseException e) { hf.printHelp(appName, options, true); } return commandLine; }
public static void printCommandLineHelp(final String appName, final Options options) { HelpFormatter hf = new HelpFormatter(); hf.setWidth(110); hf.printHelp(appName, options, true); }
private void printHelp() { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("ls [options] path", options); }
public static void printHelpGatewayModeGateway() { HelpFormatter formatter = new HelpFormatter(); formatter.setLeftPadding(5); formatter.setWidth(80); formatter.printHelp(" ", GATEWAY_MODE_GATEWAY_OPTIONS); System.out.println(); }
Options options = new Options(); Option o = new Option("t", "table", true, "table to import into (must exist)"); o.setRequired(true); options.addOption(o); o = new Option("i", "input", true, "the directory in DFS to read files from"); o.setRequired(true); options.addOption(o); options.addOption("d", "debug", false, "switch on DEBUG log level"); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(NAME + " ", options, true); System.exit(-1); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("d")) { Logger log = Logger.getLogger("mapreduce"); log.setLevel(Level.DEBUG);
private boolean parseCommandLine(String[] args) throws ParseException { Options options = new Options(); .addOption("h", "help", false, "display help text"); CommandLineParser parser = new GnuParser(); CommandLine commandLine = parser.parse(options, args); if (commandLine.hasOption('h')) { new HelpFormatter().printHelp("flume-ng avro-client", "", options, "The --dirname option assumes that a spooling directory exists " + "where immutable log files are dropped.", true); if (commandLine.hasOption("filename") && commandLine.hasOption("dirname")) { throw new ParseException( "--filename and --dirname options cannot be used simultaneously"); if (!commandLine.hasOption("port") && !commandLine.hasOption("host") && !commandLine.hasOption("rpcProps")) { throw new ParseException("Either --rpcProps or both --host and --port " + "must be specified."); if (!commandLine.hasOption("port")) { throw new ParseException( "You must specify a port to connect to with --port");
public static void main(String[] args) throws Exception { Options opt = new Options(); opt.addOption("h", false, "Print help for this application"); if (args.length == 0 || cl.hasOption('h')) { HelpFormatter f = new HelpFormatter(); f.printHelp( "Tagger:\n" + "ParserTester [option] model_file test_file result_file;\n", String[] args1 = cl.getArgs(); String modelfile = args1[0]; String testfile = args1[1];
CommandLine cli = new GnuParser().parse(opts, args); if (cli.hasOption('h')) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("fixacidkeyindex", opts); return; if (cli.hasOption("backup-path")) { backupPath = cli.getOptionValue("backup-path");
Map<String, SlowExecutorPattern> topoSpecificImbalance = new HashMap<>(); try { cmd = parser.parse(options, args); if (cmd.hasOption("t")) { executeTime = Double.valueOf(cmd.getOptionValue("t")); if (cmd.hasOption("parallel")) { for (String stringParallel : cmd.getOptionValues("parallel")) { Matcher m = MULTI_PATTERN.matcher(stringParallel); if (!m.matches()) { throw new ParseException("--parallel " + stringParallel + " is not in the format MULTIPLIER(:TOPO:COMP)?"); Matcher m = MULTI_PATTERN.matcher(stringThroughput); if (!m.matches()) { throw new ParseException("--throughput " + stringThroughput + " is not in the format MULTIPLIER(:TOPO:COMP)?"); throw new ParseException(stringImbalance + " does not appear to match the expected pattern"); } else if (parts.length == 3) { topoSpecificImbalance.put(parts[1] + ":" + parts[2], SlowExecutorPattern.fromString(parts[0])); System.err.println("ERROR " + commandLineException.getMessage()); new HelpFormatter().printHelp("GenLoad [options] [captured_file]*", options); return;
Options opts = new Options(); .create("protocol"); opts.addOption(redopt); opts.addOption(outscopt); opts.addOption(popt); opts.addOption(pargs); opts.addOption(protoopt); CommandLineParser parser = new GnuParser(); HelpFormatter formatter = new HelpFormatter(); line = parser.parse(opts, argarry); if (line.hasOption("help")) { formatter.printHelp("tether", opts ); return 0; genargs = line.getArgs(); FileInputFormat.addInputPaths(job, line.getOptionValue("in")); FileOutputFormat.setOutputPath(job,new Path (line.getOptionValue("out"))); formatter.printHelp("tether", opts ); return -1;
public static CommandLine buildCommandline(String[] args) { final Options options = new Options(); Option opt = new Option("h", "help", false, "Print help"); opt.setRequired(false); options.addOption(opt); options.addOption(opt); options.addOption(opt); PosixParser parser = new PosixParser(); HelpFormatter hf = new HelpFormatter(); hf.setWidth(110); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); if (commandLine.hasOption('h')) { hf.printHelp("producer", options, true); return null; hf.printHelp("producer", options, true); return null;
Options options = new Options(); Options help = new Options(); help.addOption(o); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; cmd = parser.parse(help,argv,true); if( cmd.getOptions().length > 0){ final HelpFormatter usageFormatter = new HelpFormatter(); usageFormatter.printHelp("HDFSDataPruner", null, options, null, true); System.exit(0); cmd = parser.parse(options, argv); final HelpFormatter usageFormatter = new HelpFormatter(); usageFormatter.printHelp("HDFSDataPruner", null, options, null, true); System.exit(-1); String start = cmd.getOptionValue("s"); Date startDate = new SimpleDateFormat("MM/dd/yyyy").parse(start); String fileSystemUri = cmd.getOptionValue("f"); Integer numDays = Integer.parseInt(cmd.getOptionValue("n")); String globString = cmd.getOptionValue("g");
/** * Parse the user-specified options, get the generic options, and modify * configuration accordingly. * * @param opts Options to use for parsing args. * @param args User-specified arguments * @return true if the parse was successful */ private boolean parseGeneralOptions(Options opts, String[] args) throws IOException { opts = buildGeneralOptions(opts); CommandLineParser parser = new GnuParser(); boolean parsed = false; try { commandLine = parser.parse(opts, preProcessForWindows(args), true); processGeneralOptions(commandLine); parsed = true; } catch(ParseException e) { LOG.warn("options parsing failed: "+e.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("general options are: ", opts); } return parsed; }
@Test public void testPrintSortedUsageWithNullComparator() { Options opts = new Options(); opts.addOption(new Option("c", "first")); opts.addOption(new Option("b", "second")); opts.addOption(new Option("a", "third")); HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setOptionComparator(null); StringWriter out = new StringWriter(); helpFormatter.printUsage(new PrintWriter(out), 80, "app", opts); assertEquals("usage: app [-c] [-b] [-a]" + EOL, out.toString()); }
public static void main(String [] args) throws ParseException, IOException, java.text.ParseException { Options options = new Options(); options.addOption(new Option("h","help", false, "Prints this message and exits.")); options.addOption(new Option("f","force", false, "Force overwrite of target file.")); PosixParser parser = new PosixParser(); CommandLine cmdline = parser.parse(options, args, false); List<String> cmdlineArgs = cmdline.getArgList(); Option [] cmdlineOptions = cmdline.getOptions(); HelpFormatter formatter = new HelpFormatter();
String config = null; try { CommandLine line = parser.parse(options, args, false); if (line.hasOption("help")) { formatter.printHelp(usage, NEW_LINE + JdrLogger.ROOT_LOGGER.jdrDescriptionMessage(), options, null); return; if (line.hasOption("host")) { host = line.getOptionValue("host"); System.out.println(e.getMessage()); formatter.printHelp(usage, options); return; } catch (NumberFormatException nfe) { System.out.println(nfe.getMessage()); formatter.printHelp(usage, options); return;
@Test public void testCLI18() { Options options = new Options(); options.addOption(new Option("a", "aaa", false, "aaaaaaa")); options.addOption(new Option(null, "bbb", false, "bbbbbbb dksh fkshd fkhs dkfhsdk fhskd hksdks dhfowehfsdhfkjshf skfhkshf sf jkshfk sfh skfh skf f")); options.addOption(new Option("c", null, false, "ccccccc")); HelpFormatter formatter = new HelpFormatter(); StringWriter out = new StringWriter(); formatter.printHelp(new PrintWriter(out), 80, "foobar", "dsfkfsh kdh hsd hsdh fkshdf ksdh fskdh fsdh fkshfk sfdkjhskjh fkjh fkjsh khsdkj hfskdhf skjdfh ksf khf s", options, 2, 2, "blort j jgj j jg jhghjghjgjhgjhg jgjhgj jhg jhg hjg jgjhghjg jhg hjg jhgjg jgjhghjg jg jgjhgjgjg jhg jhgjh" + '\r' + '\n' + "rarrr", true); } }
/** * Displays the command line help message to the standard output. */ public void printHelp() { final HelpFormatter formatter = new HelpFormatter(); final Options options = new Options(); addStandardOptions(options); if (line != null && line.hasOption(ARGUMENT.ADVANCED_HELP)) { addAdvancedOptions(options); } final String helpMsg = String.format("%n%s" + " can be used to identify if there are any known CVE vulnerabilities in libraries utilized by an application. " + "%s will automatically update required data from the Internet, such as the CVE and CPE data files from nvd.nist.gov.%n%n", settings.getString("application.name", "DependencyCheck"), settings.getString("application.name", "DependencyCheck")); formatter.printHelp(settings.getString("application.name", "DependencyCheck"), helpMsg, options, "", true); }
public static EnvBuilder builderFromArgs(String caller, String args[]) { Options options = new Options(); EnvBuilder.addStandardOptions(options); CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println("Invalid option usage: " + e.getMessage()); new HelpFormatter().printHelp(caller, options); return null; } return new EnvBuilder(cmd); }