List of usage examples for org.apache.commons.cli Options addOptionGroup
public Options addOptionGroup(OptionGroup group)
From source file:org.apache.accumulo.core.util.shell.commands.RevokeCommand.java
@Override public Options getOptions() { super.getOptions(); final Options o = new Options(); final OptionGroup group = new OptionGroup(); systemOpt = new Option("s", "system", false, "revoke a system permission"); optNamespace = new Option(Shell.namespaceOption, "namespace", true, "name of a namespace to operate on"); optNamespace.setArgName("namespace"); group.addOption(systemOpt);// ww w .j av a 2s . c o m group.addOption(optTableName); group.addOption(optTablePattern); group.addOption(optNamespace); o.addOptionGroup(group); userOpt = new Option(Shell.userOption, "user", true, "user to operate on"); userOpt.setArgName("username"); userOpt.setRequired(true); o.addOption(userOpt); return o; }
From source file:org.apache.accumulo.core.util.shell.commands.ScriptCommand.java
@Override public Options getOptions() { final Options o = new Options(); engine = new Option("e", "engine", false, "engine name, defaults to JDK default (Rhino)"); engine.setArgName("engineName"); engine.setArgs(1);//from ww w. j ava2 s . c o m engine.setRequired(false); o.addOption(engine); OptionGroup inputGroup = new OptionGroup(); list = new Option("l", "list", false, "list available script engines"); inputGroup.addOption(list); script = new Option("s", "script", true, "use inline script"); script.setArgName("script text"); script.setArgs(1); script.setRequired(false); inputGroup.addOption(script); file = new Option("f", "file", true, "use script file"); file.setArgName("fileName"); file.setArgs(1); file.setRequired(false); inputGroup.addOption(file); inputGroup.setRequired(true); o.addOptionGroup(inputGroup); OptionGroup invokeGroup = new OptionGroup(); object = new Option("obj", "object", true, "name of object"); object.setArgs(1); object.setArgName("objectName:methodName"); object.setRequired(false); invokeGroup.addOption(object); function = new Option("fx", "function", true, "invoke a script function"); function.setArgName("functionName"); function.setArgs(1); function.setRequired(false); invokeGroup.addOption(function); invokeGroup.setRequired(false); o.addOptionGroup(invokeGroup); args = new Option("a", "args", true, "comma separated list of key=value arguments"); args.setArgName("property1=value1,propert2=value2,..."); args.setArgs(Option.UNLIMITED_VALUES); args.setRequired(false); o.addOption(args); out = new Option("o", "output", true, "output file"); out.setArgName("fileName"); out.setArgs(1); out.setRequired(false); o.addOption(out); return o; }
From source file:org.apache.accumulo.core.util.shell.commands.SetAuthsCommand.java
@Override public Options getOptions() { final Options o = new Options(); final OptionGroup setOrClear = new OptionGroup(); scanOptAuths = new Option("s", "scan-authorizations", true, "scan authorizations to set"); scanOptAuths.setArgName("comma-separated-authorizations"); setOrClear.addOption(scanOptAuths);//from w w w . j av a2s . c o m clearOptAuths = new Option("c", "clear-authorizations", false, "clear the scan authorizations"); setOrClear.addOption(clearOptAuths); setOrClear.setRequired(true); o.addOptionGroup(setOrClear); userOpt = new Option(Shell.userOption, "user", true, "user to operate on"); userOpt.setArgName("user"); o.addOption(userOpt); return o; }
From source file:org.apache.accumulo.core.util.shell.commands.SetIterCommand.java
@Override public Options getOptions() { final Options o = new Options(); priorityOpt = new Option("p", "priority", true, "the order in which the iterator is applied"); priorityOpt.setArgName("pri"); priorityOpt.setRequired(true);//from w w w . ja v a 2 s. com nameOpt = new Option("n", "name", true, "iterator to set"); nameOpt.setArgName("itername"); allScopeOpt = new Option("all", "all-scopes", false, "applied at scan time, minor and major compactions"); mincScopeOpt = new Option(IteratorScope.minc.name(), "minor-compaction", false, "applied at minor compaction"); majcScopeOpt = new Option(IteratorScope.majc.name(), "major-compaction", false, "applied at major compaction"); scanScopeOpt = new Option(IteratorScope.scan.name(), "scan-time", false, "applied at scan time"); final OptionGroup typeGroup = new OptionGroup(); classnameTypeOpt = new Option("class", "class-name", true, "a java class that implements SortedKeyValueIterator"); classnameTypeOpt.setArgName("name"); aggTypeOpt = new Option("agg", "aggregator", false, "an aggregating type"); regexTypeOpt = new Option("regex", "regular-expression", false, "a regex matching iterator"); versionTypeOpt = new Option("vers", "version", false, "a versioning iterator"); reqvisTypeOpt = new Option("reqvis", "require-visibility", false, "an iterator that omits entries with empty visibilities"); ageoffTypeOpt = new Option("ageoff", "ageoff", false, "an aging off iterator"); typeGroup.addOption(classnameTypeOpt); typeGroup.addOption(aggTypeOpt); typeGroup.addOption(regexTypeOpt); typeGroup.addOption(versionTypeOpt); typeGroup.addOption(reqvisTypeOpt); typeGroup.addOption(ageoffTypeOpt); typeGroup.setRequired(true); final OptionGroup tableGroup = new OptionGroup(); tableGroup.addOption(OptUtil.tableOpt("table to configure iterators on")); tableGroup.addOption(OptUtil.namespaceOpt("namespace to configure iterators on")); o.addOption(priorityOpt); o.addOption(nameOpt); o.addOption(allScopeOpt); o.addOption(mincScopeOpt); o.addOption(majcScopeOpt); o.addOption(scanScopeOpt); o.addOptionGroup(typeGroup); o.addOptionGroup(tableGroup); return o; }
From source file:org.apache.accumulo.core.util.shell.commands.SetScanIterCommand.java
@Override public Options getOptions() { // Remove the options that specify which type of iterator this is, since // they are all scan iterators with this command. final HashSet<OptionGroup> groups = new HashSet<OptionGroup>(); final Options parentOptions = super.getOptions(); final Options modifiedOptions = new Options(); for (Iterator<?> it = parentOptions.getOptions().iterator(); it.hasNext();) { Option o = (Option) it.next(); if (!IteratorScope.majc.name().equals(o.getOpt()) && !IteratorScope.minc.name().equals(o.getOpt()) && !IteratorScope.scan.name().equals(o.getOpt())) { modifiedOptions.addOption(o); OptionGroup group = parentOptions.getOptionGroup(o); if (group != null) groups.add(group);/*w w w .j a v a2 s . c o m*/ } } for (OptionGroup group : groups) { modifiedOptions.addOptionGroup(group); } return modifiedOptions; }
From source file:org.apache.accumulo.core.util.shell.commands.SetShellIterCommand.java
@Override public Options getOptions() { // Remove the options that specify which type of iterator this is, since // they are all scan iterators with this command. final HashSet<OptionGroup> groups = new HashSet<OptionGroup>(); final Options parentOptions = super.getOptions(); final Options modifiedOptions = new Options(); for (Iterator<?> it = parentOptions.getOptions().iterator(); it.hasNext();) { Option o = (Option) it.next(); if (!IteratorScope.majc.name().equals(o.getOpt()) && !IteratorScope.minc.name().equals(o.getOpt()) && !IteratorScope.scan.name().equals(o.getOpt()) && !"table".equals(o.getLongOpt())) { modifiedOptions.addOption(o); OptionGroup group = parentOptions.getOptionGroup(o); if (group != null) groups.add(group);// w w w .ja v a 2 s .c om } } for (OptionGroup group : groups) { modifiedOptions.addOptionGroup(group); } profileOpt = new Option("pn", "profile", true, "iterator profile name"); profileOpt.setRequired(true); profileOpt.setArgName("profile"); modifiedOptions.addOption(profileOpt); return modifiedOptions; }
From source file:org.apache.accumulo.core.util.shell.commands.ShellPluginConfigurationCommand.java
@Override public Options getOptions() { final Options o = new Options(); final OptionGroup actionGroup = new OptionGroup(); pluginClassOption = new Option(classOpt, pluginType, true, "fully qualified name of the " + pluginType + " class to use"); pluginClassOption.setArgName("className"); // Action to take: apply (default), remove, list removePluginOption = new Option("r", "remove", false, "remove the current " + pluginType + ""); listPluginOption = new Option("l", "list", false, "display the current " + pluginType + ""); actionGroup.addOption(pluginClassOption); actionGroup.addOption(removePluginOption); actionGroup.addOption(listPluginOption); actionGroup.setRequired(true);/*from www. j a va2s . c om*/ o.addOptionGroup(actionGroup); o.addOption(OptUtil.tableOpt("table to set the " + pluginType + " on")); return o; }
From source file:org.apache.accumulo.core.util.shell.commands.TableOperation.java
@Override public Options getOptions() { final Options o = new Options(); optTablePattern = new Option("p", "pattern", true, "regex pattern of table names to operate on"); optTablePattern.setArgName("pattern"); optTableName = new Option(Shell.tableOption, "table", true, "name of a table to operate on"); optTableName.setArgName("tableName"); optNamespace = new Option(Shell.namespaceOption, "namespace", true, "name of a namespace to operate on"); optNamespace.setArgName("namespace"); final OptionGroup opg = new OptionGroup(); opg.addOption(optTablePattern);//from w ww . j a v a2 s . co m opg.addOption(optTableName); opg.addOption(optNamespace); o.addOptionGroup(opg); return o; }
From source file:org.apache.accumulo.shell.commands.AddAuthsCommand.java
@Override public Options getOptions() { final Options o = new Options(); final OptionGroup setOrClear = new OptionGroup(); scanOptAuths = new Option("s", "scan-authorizations", true, "scan authorizations to set"); scanOptAuths.setArgName("comma-separated-authorizations"); setOrClear.addOption(scanOptAuths);/*from w w w. j a v a 2 s . c o m*/ setOrClear.setRequired(true); o.addOptionGroup(setOrClear); userOpt = new Option(ShellOptions.userOption, "user", true, "user to operate on"); userOpt.setArgName("user"); o.addOption(userOpt); return o; }
From source file:org.apache.accumulo.shell.commands.ConfigCommand.java
@Override public Options getOptions() { final Options o = new Options(); final OptionGroup og = new OptionGroup(); final OptionGroup tgroup = new OptionGroup(); tableOpt = new Option(ShellOptions.tableOption, "table", true, "table to display/set/delete properties for"); deleteOpt = new Option("d", "delete", true, "delete a per-table property"); setOpt = new Option("s", "set", true, "set a per-table property"); filterOpt = new Option("f", "filter", true, "show only properties that contain this string"); disablePaginationOpt = new Option("np", "no-pagination", false, "disables pagination of output"); outputFileOpt = new Option("o", "output", true, "local file to write the scan output to"); namespaceOpt = new Option(ShellOptions.namespaceOption, "namespace", true, "namespace to display/set/delete properties for"); tableOpt.setArgName("table"); deleteOpt.setArgName("property"); setOpt.setArgName("property=value"); filterOpt.setArgName("string"); outputFileOpt.setArgName("file"); namespaceOpt.setArgName("namespace"); og.addOption(deleteOpt);//from w ww. j av a 2s .com og.addOption(setOpt); og.addOption(filterOpt); tgroup.addOption(tableOpt); tgroup.addOption(namespaceOpt); o.addOptionGroup(tgroup); o.addOptionGroup(og); o.addOption(disablePaginationOpt); o.addOption(outputFileOpt); return o; }