public static void addOption(final Options options, final String opt, final String argName, final boolean hasArg, final String description, final boolean isRequired) { final Option option = new Option(opt, hasArg, description); option.setArgName(argName); option.setRequired(isRequired); options.addOption(option); }
@Before public void setUp() { options = new Options(); Option algorithm = new Option("a" , "algo", true, "the algorithm which it to perform executing"); algorithm.setArgName("algorithm name"); options.addOption(algorithm); Option key = new Option("k" , "key", true, "the key the setted algorithm uses to process"); algorithm.setArgName("value"); options.addOption(key); parser = new PosixParser(); }
@Test public void testPrintOptionWithEmptyArgNameUsage() { Option option = new Option("f", true, null); option.setArgName(""); option.setRequired(true); Options options = new Options(); options.addOption(option); StringWriter out = new StringWriter(); HelpFormatter formatter = new HelpFormatter(); formatter.printUsage(new PrintWriter(out), 80, "app", options); assertEquals("usage: app -f" + EOL, out.toString()); }
@Test public void testHasArgName() { Option option = new Option("f", null); option.setArgName(null); assertFalse(option.hasArgName()); option.setArgName(""); assertFalse(option.hasArgName()); option.setArgName("file"); assertTrue(option.hasArgName()); }
option.setType(type); option.setValueSeparator(valuesep); option.setArgName(argName);
/** * Creates cli options. * * @return Command line options */ private static Options createOptions() { Options options = new Options(); OptionGroup grp = new OptionGroup(); grp.setRequired(true); Option cfg = new Option(OPTION_CFG, null, true, "path to Spring XML configuration file."); cfg.setArgName("file"); Option n = new Option(null, OPTION_N, true, "nodes count."); n.setValueSeparator('='); n.setType(Integer.class); grp.addOption(cfg); grp.addOption(n); options.addOptionGroup(grp); return options; } }
public static Option endRowOpt() { final Option o = new Option(END_ROW_OPT, "end-row", true, "end row (inclusive)"); o.setArgName("end-row"); return o; }
public static Option tableOpt(final String description) { final Option tableOpt = new Option(ShellOptions.tableOption, "table", true, description); tableOpt.setArgName("table"); tableOpt.setRequired(false); return tableOpt; }
@Override public Option apply(@Nullable String s) { Option o = new Option(s, "tmp_dir", true, "Directory for landing the temporary GeoLite2 data - defaults to /tmp"); o.setArgName("TMP_DIR"); o.setRequired(false); return o; } }),
@Nullable @Override public Option apply(@Nullable String s) { Option o = new Option(s, "time_between_polls", true, "The time between polls (in ms)"); o.setArgName("MS"); o.setRequired(false); return o; } })
@Nullable @Override public Option apply(@Nullable String s) { Option o = new Option(s, "log4j", true, "The log4j properties file to load"); o.setArgName("FILE"); o.setRequired(false); return o; } })
@Nullable @Override public Option apply(@Nullable String s) { Option o = new Option(s, "enrichment_config", true , "JSON Document describing the enrichment configuration details." + " This is used to associate an enrichment type with a field type in zookeeper." ); o.setArgName("JSON_FILE"); o.setRequired(false); return o; } })
@Nullable @Override public Option apply(@Nullable String s) { Option o = new Option(s, "log4j", true, "The log4j properties file to load"); o.setArgName("FILE"); o.setRequired(false); return o; }
@Nullable @Override public Option apply(@Nullable String s) { Option o = new Option(s, "lookback", true, "When summarizing, how many monitoring periods should we summarize over? If 0, then no summary. Default: 5"); o.setArgName("LOOKBACK"); o.setRequired(false); return o; }
@Nullable @Override public Option apply(@Nullable String s) { Option o = new Option(s, "eps", true, "The target events per second"); o.setArgName("EPS"); o.setRequired(false); return o; }
@Nullable @Override public Option apply(@Nullable String s) { Option o = new Option(s, "hbase_table", true, "HBase table to ingest the data into."); o.setArgName("TABLE"); o.setRequired(true); return o; }
@Override public Options getOptions() { final Options opts = new Options(); tserverOption = new Option("ts", "tabletServer", true, "tablet server to list scans for"); tserverOption.setArgName("tablet server"); opts.addOption(tserverOption); disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output"); opts.addOption(disablePaginationOpt); return opts; }
@Override public Options getOptions() { final Options opts = new Options(); tserverOption = new Option("ts", "tabletServer", true, "tablet server to list bulk imports"); tserverOption.setArgName("tablet server"); opts.addOption(tserverOption); disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output"); opts.addOption(disablePaginationOpt); return opts; }
@Override public Options getOptions() { final Options opts = new Options(); filterOption = new Option("f", "filter", true, "show only compactions that match the regex"); opts.addOption(filterOption); tserverOption = new Option("ts", "tabletServer", true, "tablet server to list compactions for"); tserverOption.setArgName("tablet server"); opts.addOption(tserverOption); disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output"); opts.addOption(disablePaginationOpt); return opts; }
@Nullable @Override public Option apply(@Nullable String s) { Option o = new Option(s, "percentiles", true , "Percentiles to calculate per run. Default: " + Joiner.on(",").join(Arrays.asList(DEFAULT_PERCENTILES)) ); o.setArgName("NUM"); o.setRequired(false); return o; }