Refine search
public SetQuotaCommand() { super("setquota", "-n|-b val path"); OptionGroup og1 = new OptionGroup(); og1.addOption(new Option("b", true, "bytes quota")); og1.addOption(new Option("n", true, "num quota")); og1.setRequired(true); options.addOptionGroup(og1); }
@Test public void testOptionGroupLong() throws Exception { OptionGroup group = new OptionGroup(); group.addOption(OptionBuilder.withLongOpt("foo").create()); group.addOption(OptionBuilder.withLongOpt("bar").create()); Options options = new Options(); options.addOptionGroup(group); CommandLine cl = parser.parse(options, new String[] { "--bar" }); assertTrue(cl.hasOption("bar")); assertEquals("selected option", "bar", group.getSelected()); }
Options options1 = new Options(); options1.add(OptionsBuilder.withLongOpt("help").create("h")); options1.add(OptionsBuilder.withLongOpt("version").create()); if (!cl.getOptions().isEmpty()) { OptionGroup group = new OptionGroup(); group.add(OptionsBuilder.withLongOpt("input").hasArg().create("i")); group.add(OptionsBuilder.withLongOpt("output").hasArg().create("o")); group.setRequired(true); Options options2 = new Options();
public static void main(String[] args) { MetastoreSchemaTool tool = new HiveSchemaTool(); OptionGroup additionalGroup = new OptionGroup(); Option metaDbTypeOpt = OptionBuilder.withArgName("metaDatabaseType") .hasArgs().withDescription("Used only if upgrading the system catalog for hive") .create("metaDbType"); additionalGroup.addOption(metaDbTypeOpt); System.setProperty(MetastoreConf.ConfVars.SCHEMA_VERIFICATION.getVarname(), "true"); System.exit(tool.run(System.getenv("HIVE_HOME"), args, additionalGroup, new HiveConf(HiveSchemaTool.class))); } }
OptionGroup optionsGroup = new OptionGroup(); optionsGroup.setRequired(true); Option listOption = new Option("l", "list", false, "List DLP Jobs"); optionsGroup.addOption(listOption); Option deleteOption = new Option("d", "delete", false, "Delete DLP Jobs"); optionsGroup.addOption(deleteOption); Options commandLineOptions = new Options(); commandLineOptions.addOptionGroup(optionsGroup); Option projectIdOption = Option.builder("projectId").hasArg(true).required(false).build(); commandLineOptions.addOption(projectIdOption); Option filterOption = Option.builder("filter").hasArg(true).required(false).build(); cmd.getOptionValue(projectIdOption.getOpt(), ServiceOptions.getDefaultProjectId()); if (cmd.hasOption(listOption.getOpt())) { String filter = cmd.getOptionValue(filterOption.getOpt(), ""); DlpJobType jobType = DlpJobType.valueOf(
" admin user and the hive password to the db admin password with this"); OptionGroup optGroup = new OptionGroup(); optGroup .addOption(help) .addOption(infoOpt) .addOption(upgradeOpt) .addOption(upgradeFromOpt) .addOption(initOpt) .addOption(initToOpt) .addOption(initOrUpgradeSchemaOpt) .addOption(validateOpt) .addOption(createCatalog) .addOption(alterCatalog) .addOption(moveDatabase) .addOption(moveTable) .addOption(createUserOpt); optGroup.setRequired(true); Options options = new Options(); options.addOption(help); options.addOptionGroup(optGroup);
private static Options buildCliOptions() { Options opts = new Options(); Option file = OptionBuilder.withArgName("pathsFile").hasArg() .withDescription("a local file containing files/dirs to migrate") .create("f"); Option paths = OptionBuilder.withArgName("paths").hasArgs() .withDescription("specify space separated files/dirs to migrate") .create("p"); OptionGroup group = new OptionGroup(); group.addOption(file); group.addOption(paths); opts.addOptionGroup(group); return opts; }
private static Options parseCommandLineOptions() { Option helpOption = OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info") .create(); OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address").create(); zkServerOption.setArgs(1); zkServerOption.setRequired(true); zkServerOption.setArgName("ZookeeperServerAddress(Required)"); sessionOption.setArgName("Session name"); OptionGroup optionGroup = new OptionGroup(); optionGroup.addOption(zkServerOption); Options options = new Options(); options.addOption(helpOption); options.addOption(clusterOption); options.addOption(instanceOption); options.addOption(sessionOption);
Options options = new Options(); options.addOption(VERB_DELETE); final OptionGroup identityOptions = new OptionGroup(); identityOptions.addOption(OPT_EMAIL); identityOptions.addOption(OPT_NETID); options.addOptionGroup(identityOptions); options.addOption("h", "help", false, "explain --delete options"); if (command.hasOption('h')) { new HelpFormatter().printHelp("user --delete [options]", options); return 0; if (command.hasOption(OPT_NETID.getOpt())) { eperson = ePersonService.findByNetid(context, command.getOptionValue(OPT_NETID.getOpt())); } else if (command.hasOption(OPT_EMAIL.getOpt())) { eperson = ePersonService.findByEmail(context, command.getOptionValue(OPT_EMAIL.getOpt())); } else {
public int run(String[] args) throws Exception { Option helpOption = new Option("h", "help", false, "Shows this message. Additionally specify the " + MAPPER_CLASS_NAME + " argument to show help for a specific mapper class."); Options options = new Options(); options.addOption(helpOption); options.addOption(OptionBuilder.withArgName("NN URI").hasArg().withDescription("URI of the NameNode under test") .isRequired().create(NN_URI)); OptionGroup startTimeOptions = new OptionGroup(); startTimeOptions.addOption(OptionBuilder.withArgName("Start Timestamp").hasArg() .withDescription("Mapper start UTC timestamp in ms").create(START_TIMESTAMP_MS)); startTimeOptions.addOption(OptionBuilder.withArgName("Start Time Offset").hasArg() .withDescription("Mapper start time as an offset from current time. Human-readable formats accepted, " + "e.g. 10m (default " + START_TIME_OFFSET_DEFAULT + ").").create(START_TIME_OFFSET)); Options helpOptions = new Options(); helpOptions.addOption(helpOption); Option mapperClassNotRequiredOption = (Option) mapperClassOption.clone(); mapperClassNotRequiredOption.setRequired(false); helpOptions.addOption(mapperClassNotRequiredOption); if (cli.hasOption("h")) { String footer = null; if (cli.hasOption(MAPPER_CLASS_NAME)) { footer = getMapperUsageInfo(cli.getOptionValue(MAPPER_CLASS_NAME));
Options options = new Options(); options.addOption(OptionBuilder .withArgName("prop") .hasArg() .withDescription( OptionGroup og = new OptionGroup(); og.addOption(OptionBuilder og.addOption(OptionBuilder og.setRequired(true); options.addOptionGroup(og); try { CommandLineParser parser = new GnuParser(); Properties props = new Properties(System.getProperties()); props.putAll(FileUtil.loadProperties( line.getOptionValue("prop"), true)); if (!cytHelper.validateProps(props)) { printHelp(options); } else { if (line.hasOption("network")) { cytHelper.exportNetwork(line.getOptionValue("network"),
private static CommandLine parseComandLine(String[] args) throws ParseException { Options opts = new Options(); CLIUtils.addCommonOptions(opts); opts.addOption(Option.builder("m") .hasArgs() .argName("[seq/]attr=value") .desc(rb.getString("metadata")) .build()); opts.addOption(Option.builder("f") .hasArg() .argName("xml-file") .desc(rb.getString("file")) .build()); OptionGroup group = new OptionGroup(); group.addOption(Option.builder() .longOpt("pdf") .hasArg(false) .desc(rb.getString("pdf")) .build()); group.addOption(Option.builder() .longOpt("cda") .hasArg(false) opts.addOptionGroup(group); CommandLine cl = CLIUtils.parseComandLine(args, opts, rb, Pdf2Dcm.class); int numArgs = cl.getArgList().size(); if (numArgs == 0) throw new ParseException(rb.getString("missing"));
@SuppressWarnings("static-access") private static Options buildOptions() { Options result = new Options(); OptionGroup query = new OptionGroup(); Option path = OptionBuilder.withArgName("path").hasArg().withDescription("LD Path to evaluate on the file starting from the context").create("path"); Option program = OptionBuilder.withArgName("file").hasArg().withDescription("LD Path program to evaluate on the file starting from the context").create("program"); query.addOption(path); query.addOption(program); query.setRequired(true); result.addOptionGroup(query); Option context = OptionBuilder.withArgName("uri").hasArg().withDescription("URI of the context node to start from").create("context"); context.setRequired(true); result.addOption(context); Option loglevel = OptionBuilder.withArgName("level").hasArg().withDescription("set the log level; default is 'warn'").create("loglevel"); result.addOption(loglevel); Option store = OptionBuilder.withArgName("dir").hasArg().withDescription("cache the retrieved data in this directory").create("store"); result.addOption(store); Option format = OptionBuilder.withArgName("format").hasArg().withDescription("output format").create("format"); result.addOption(format); return result; }
@SuppressWarnings("static-access") private static CommandLine parseComandLine(String[] args, OptionGroup cmdGroup) throws ParseException { Options opts = new Options(); CLIUtils.addCommonOptions(opts); cmdGroup.addOption(Option.builder("c") .hasArg() .argName("aet@host:port") .desc(rb.getString("create")) .build()); cmdGroup.addOption(Option.builder("a") .hasArg() .argName("aet@host:port") .desc(rb.getString("add")) .build()); cmdGroup.addOption(Option.builder("d") .hasArg() .argName("aet") .desc(rb.getString("delete")) .build()); opts.addOptionGroup(cmdGroup); opts.addOption(Option.builder("H") .hasArg() .argName("ldapuri") CLIUtils.addTLSCipherOptions(opts); CommandLine cl = CLIUtils.parseComandLine(args, opts, rb, DcmLdap.class); String selected = cmdGroup.getSelected(); if (selected == null) throw new ParseException(rb.getString("missing")); if (selected.equals("a") && !cl.hasOption("dev"))
boolean isDebug = cl.hasOption('d'); if (isDebug) args = (String[]) ArrayUtils.removeElement(args, "-d"); if (LAUNCH_TYPE.getSelected() == null) LAUNCH_TYPE.setSelected(OPTIONS.getOption("v")); if (LAUNCH_TYPE.getSelected().equals("v")) } else if (LAUNCH_TYPE.getSelected().equals("r")) final Options R_OPTIONS = new Options(); final Option plugin = new Option(null, "plugin", true, "Class name of the tool/plugin"); plugin.setRequired(true); plugin.setType(PatternOptionBuilder.CLASS_VALUE); plugin.setArgName("Tool/Plugin"); R_OPTIONS.addOption(plugin); final Option routine = new Option(null, "routine", true, "(Optional) Tool/Plugin launch mode. By default launches mode 1."); final String inputPlugin = cmd.getOptionValue("plugin"); if (cmd.hasOption("package-name")) packageName = cmd.getOptionValue("package-name"); throw new ParseException("Unknown launch option: " + LAUNCH_TYPE.getSelected());
public static void main( String[] args ) { // create Options object Options options = new Options(); options.addOption("id", true, "exporter ID"); OptionGroup outputOptions = new OptionGroup(); outputOptions.addOption(new Option("stdout", "Print audit log messages to the stdout")); outputOptions.addOption(new Option("tcp", "sends audit log messages to the host:port over TCP")); outputOptions.addOption(new Option("udp", "sends audit log messages to the host:port over UDP")); options.addOptionGroup(outputOptions); CommandLineParser parser = new BasicParser(); CommandLine cmd; try { cmd = parser.parse(options, args); String exporterId = cmd.getOptionValue("id"); if (exporterId == null) { System.err.println("Exporter ID must be specified."); System.exit(1); } OutputType outputType = cmd.hasOption("stdout") ? OutputType.STDOUT : cmd.hasOption("tcp") ? OutputType.TCP : cmd.hasOption("udp") ? OutputType.UDP : OutputType.STDOUT; ExporterStarter exporter = new ExporterStarter(outputType); exporter.run(exporterId); } catch (ParseException e) { help(options); System.exit(1); } }
Options mainOptions = new Options(); OptionGroup grp = new OptionGroup(); grp.addOption(new Option("exec",false,"description for this option")); grp.addOption(new Option("rep",false,"description for this option")); mainOptions.addOptionGroup(grp); Options execOptions = new Options(); execOptions.addOption("exec_opt1", false, " desc"); execOptions.addOption("exec_opt2", false, " desc"); argv = cmd.getArgs(); if(cmd.hasOption("exec")) assertTrue( cmd.hasOption("exec_opt1") ); assertTrue( cmd.hasOption("exec_opt2") );
Options options = new Options(); options.addOption(new Option("h", "help", false, "Print this message")); options.addOption(new Option("o", "optimize", false, "Optimize the Solr index")); options.addOption(new Option("d", "delete", false, "Delete item before indexing")); options.addOption(OptionBuilder.withArgName("Solr URL").hasArg() .withDescription("URL to the Solr instance").withLongOpt("solrUrl") .create("su")); options.addOption(OptionBuilder.withArgName("Filemgr URL").hasArg() .create("fmu")); OptionGroup group = new OptionGroup(); Option all = new Option("a", "all", false, "Index all products from the File Manager"); "Delete all products/types from the Solr index"); group.addOption(all); group.addOption(product); group.addOption(met); group.addOption(read); group.addOption(types); group.addOption(deleteAll); options.addOptionGroup(group);
final String USAGE = "Groomer -verb [option...]"; OptionGroup verbs = new OptionGroup(); verbs.setRequired(true); verbs.addOption(new Option("h", "help", false, "explain this tool")); verbs.addOption(new Option("a", "aging", false, "discover accounts not used recently")); verbs.addOption(new Option("u", "unsalted", false, "list accounts with unsalted password hashes")); Options options = new Options(); options.addOptionGroup(verbs); options.addOption("b", "last-used-before", true, "date of last login was before this (for example: " + dateFormat.get().format(Calendar.getInstance().getTime()) if (null == command || command.hasOption('h') || command.hasOption('?')) { new HelpFormatter().printHelp(USAGE, options); System.exit(0); } else if (command.hasOption('a')) { } else { System.err.println("Unimplemented verb: " + verbs.getSelected());
@SuppressWarnings("static-access") private static CommandLine parseComandLine(String[] args) throws ParseException{ Options opts = new Options(); CLIUtils.addCommonOptions(opts); CLIUtils.addFilesetInfoOptions(opts); OptionGroup cmdGroup = new OptionGroup(); addCommandOptions(cmdGroup); opts.addOptionGroup(cmdGroup); opts.addOption(Option.builder("w") .longOpt("width") .hasArg() .build()); opts.addOption(null, "in-use", false, rb.getString("in-use")); opts.addOption(Option.builder() .longOpt("csv") .hasArg() CLIUtils.addEncodingOptions(opts); CommandLine cl = CLIUtils.parseComandLine(args, opts, rb, DcmDir.class); if (cmdGroup.getSelected() == null) throw new ParseException(rb.getString("missing")); return cl;