List of usage examples for org.apache.commons.cli OptionGroup OptionGroup
OptionGroup
From source file:org.apache.rat.Report.java
private static Options buildOptions() { Options opts = new Options(); Option help = new Option("h", "help", false, "Print help for the Rat command line interface and exit"); opts.addOption(help);//from www. j ava2 s .c o m OptionGroup addLicenceGroup = new OptionGroup(); String addLicenceDesc = "Add the default licence header to any file with an unknown licence that is not in the exclusion list. By default new files will be created with the licence header, to force the modification of existing files use the --force option."; Option addLicence = new Option("a", "addLicence", false, addLicenceDesc); addLicenceGroup.addOption(addLicence); Option addLicense = new Option("A", "addLicense", false, addLicenceDesc); addLicenceGroup.addOption(addLicense); opts.addOptionGroup(addLicenceGroup); Option write = new Option("f", "force", false, "Forces any changes in files to be written directly to the source files (i.e. new files are not created)"); opts.addOption(write); Option copyright = new Option("c", "copyright", true, "The copyright message to use in the licence headers, usually in the form of \"Copyright 2008 Foo\""); opts.addOption(copyright); @SuppressWarnings("static-access") // ignore OptionBuilder design fault final Option exclude = OptionBuilder.withArgName("expression").withLongOpt("exclude").hasArgs() .withDescription("Excludes files matching wildcard <expression>. " + "Note that --dir is required when using this parameter. " + "Allows multiple arguments.") .create(EXCLUDE_CLI); opts.addOption(exclude); @SuppressWarnings("static-access") // ignore OptionBuilder design fault final Option excludeFile = OptionBuilder.withArgName("fileName").withLongOpt("exclude-file").hasArgs() .withDescription("Excludes files matching regular expression in <file> " + "Note that --dir is required when using this parameter. ") .create(EXCLUDE_FILE_CLI); opts.addOption(excludeFile); Option dir = new Option("d", "dir", false, "Used to indicate source when using --exclude"); opts.addOption(dir); OptionGroup outputType = new OptionGroup(); Option xml = new Option("x", "xml", false, "Output the report in raw XML format. Not compatible with -s"); outputType.addOption(xml); Option xslt = new Option(String.valueOf(STYLESHEET_CLI), "stylesheet", true, "XSLT stylesheet to use when creating the" + " report. Not compatible with -x"); outputType.addOption(xslt); opts.addOptionGroup(outputType); return opts; }
From source file:org.apache.reef.runtime.hdinsight.cli.HDICLI.java
@Inject HDICLI(final HDInsightInstance hdInsightInstance, final LogFetcher logFetcher) { this.hdInsightInstance = hdInsightInstance; this.logFetcher = logFetcher; final OptionGroup commands = new OptionGroup() .addOption(OptionBuilder.withArgName(KILL).hasArg().withDescription("Kills the given application.") .create(KILL))/* ww w .j a v a 2 s.com*/ .addOption(OptionBuilder.withArgName(LOGS).hasArg() .withDescription("Fetches the logs for the given application.").create(LOGS)) .addOption(OptionBuilder.withArgName(STATUS).hasArg() .withDescription("Fetches the status for the given application.").create(STATUS)) .addOption(OptionBuilder.withArgName(LIST).withDescription("Lists the application on the cluster.") .create(LIST)); this.options = new Options().addOptionGroup(commands); }
From source file:org.apache.sentry.binding.hive.authz.SentryConfigTool.java
/** * parse arguments/* w w w . j a v a 2 s .c o m*/ * * <pre> * -d,--debug Enable debug output * -e,--query <arg> Query privilege verification, requires -u * -h,--help Print usage * -i,--policyIni <arg> Policy file path * -j,--jdbcURL <arg> JDBC URL * -l,--listPrivs,--listPerms List privilges for given user, requires -u * -p,--password <arg> Password * -s,--sentry-site <arg> sentry-site file path * -u,--user <arg> user name * -v,--validate Validate policy file * -I,--import Import policy file * -E,--export Export policy file * -o,--overwrite Overwrite the exist role data when do the import * </pre> * * @param args */ private void parseArgs(String[] args) { boolean enableDebug = false; Options sentryOptions = new Options(); Option helpOpt = new Option("h", "help", false, "Print usage"); helpOpt.setRequired(false); Option validateOpt = new Option("v", "validate", false, "Validate policy file"); validateOpt.setRequired(false); Option queryOpt = new Option("e", "query", true, "Query privilege verification, requires -u"); queryOpt.setRequired(false); Option listPermsOpt = new Option("l", "listPerms", false, "list permissions for given user, requires -u"); listPermsOpt.setRequired(false); Option listPrivsOpt = new Option("listPrivs", false, "list privileges for given user, requires -u"); listPrivsOpt.setRequired(false); Option importOpt = new Option("I", "import", true, "Import policy file"); importOpt.setRequired(false); Option exportOpt = new Option("E", "export", true, "Export policy file"); exportOpt.setRequired(false); // required args OptionGroup sentryOptGroup = new OptionGroup(); sentryOptGroup.addOption(helpOpt); sentryOptGroup.addOption(validateOpt); sentryOptGroup.addOption(queryOpt); sentryOptGroup.addOption(listPermsOpt); sentryOptGroup.addOption(listPrivsOpt); sentryOptGroup.addOption(importOpt); sentryOptGroup.addOption(exportOpt); sentryOptGroup.setRequired(true); sentryOptions.addOptionGroup(sentryOptGroup); // optional args Option jdbcArg = new Option("j", "jdbcURL", true, "JDBC URL"); jdbcArg.setRequired(false); sentryOptions.addOption(jdbcArg); Option sentrySitePath = new Option("s", "sentry-site", true, "sentry-site file path"); sentrySitePath.setRequired(false); sentryOptions.addOption(sentrySitePath); Option globalPolicyPath = new Option("i", "policyIni", true, "Policy file path"); globalPolicyPath.setRequired(false); sentryOptions.addOption(globalPolicyPath); Option userOpt = new Option("u", "user", true, "user name"); userOpt.setRequired(false); sentryOptions.addOption(userOpt); Option passWordOpt = new Option("p", "password", true, "Password"); userOpt.setRequired(false); sentryOptions.addOption(passWordOpt); Option debugOpt = new Option("d", "debug", false, "enable debug output"); debugOpt.setRequired(false); sentryOptions.addOption(debugOpt); Option overwriteOpt = new Option("o", "overwrite", false, "enable import overwrite"); overwriteOpt.setRequired(false); sentryOptions.addOption(overwriteOpt); try { Parser parser = new GnuParser(); CommandLine cmd = parser.parse(sentryOptions, args); for (Option opt : cmd.getOptions()) { if (opt.getOpt().equals("s")) { setSentrySiteFile(opt.getValue()); } else if (opt.getOpt().equals("i")) { setPolicyFile(opt.getValue()); } else if (opt.getOpt().equals("e")) { setQuery(opt.getValue()); } else if (opt.getOpt().equals("j")) { setJdbcURL(opt.getValue()); } else if (opt.getOpt().equals("u")) { setUser(opt.getValue()); } else if (opt.getOpt().equals("p")) { setPassWord(opt.getValue()); } else if (opt.getOpt().equals("l") || opt.getOpt().equals("listPrivs")) { setListPrivs(true); } else if (opt.getOpt().equals("v")) { setValidate(true); } else if (opt.getOpt().equals("I")) { setImportPolicyFilePath(opt.getValue()); } else if (opt.getOpt().equals("E")) { setExportPolicyFilePath(opt.getValue()); } else if (opt.getOpt().equals("h")) { usage(sentryOptions); } else if (opt.getOpt().equals("d")) { enableDebug = true; } else if (opt.getOpt().equals("o")) { setImportOverwriteRole(true); } } if (isListPrivs() && (getUser() == null)) { throw new ParseException("Can't use -l without -u "); } if ((getQuery() != null) && (getUser() == null)) { throw new ParseException("Must use -u with -e "); } } catch (ParseException e1) { usage(sentryOptions); } if (!enableDebug) { // turn off log LogManager.getRootLogger().setLevel(Level.OFF); } }
From source file:org.apache.sentry.cli.tools.SentrySchemaTool.java
@SuppressWarnings("static-access") private static void initOptions(Options cmdLineOptions) { Option help = new Option("help", "print this message"); Option upgradeOpt = new Option("upgradeSchema", "Schema upgrade"); Option upgradeFromOpt = OptionBuilder.withArgName("upgradeFrom").hasArg() .withDescription("Schema upgrade from a version").create("upgradeSchemaFrom"); Option initOpt = new Option("initSchema", "Schema initialization"); Option initToOpt = OptionBuilder.withArgName("initTo").hasArg() .withDescription("Schema initialization to a version").create("initSchemaTo"); Option infoOpt = new Option("info", "Show config and schema details"); OptionGroup optGroup = new OptionGroup(); optGroup.addOption(upgradeOpt).addOption(initOpt).addOption(help).addOption(upgradeFromOpt) .addOption(initToOpt).addOption(infoOpt); optGroup.setRequired(true);/* w w w . j ava2s . c o m*/ Option userNameOpt = OptionBuilder.withArgName("user").hasArg() .withDescription("Override config file user name").create("userName"); Option passwdOpt = OptionBuilder.withArgName("password").hasArg() .withDescription("Override config file password").create("passWord"); Option dbTypeOpt = OptionBuilder.withArgName("databaseType").hasArg() .withDescription("Sentry store database type [" + SentrySchemaHelper.DB_DERBY + "," + SentrySchemaHelper.DB_MYSQL + "," + SentrySchemaHelper.DB_ORACLE + "," + SentrySchemaHelper.DB_POSTGRACE + "," + SentrySchemaHelper.DB_DB2 + "]") .create("dbType"); Option dbOpts = OptionBuilder.withArgName("databaseOpts").hasArgs() .withDescription("Backend DB specific options").create("dbOpts"); Option dryRunOpt = new Option("dryRun", "list SQL scripts (no execute)"); Option verboseOpt = new Option("verbose", "only print SQL statements"); Option configOpt = OptionBuilder.withArgName("confName").hasArgs() .withDescription("Sentry Service configuration file").isRequired(true) .create(ServiceConstants.ServiceArgs.CONFIG_FILE_LONG); cmdLineOptions.addOption(help); cmdLineOptions.addOption(dryRunOpt); cmdLineOptions.addOption(userNameOpt); cmdLineOptions.addOption(passwdOpt); cmdLineOptions.addOption(dbTypeOpt); cmdLineOptions.addOption(verboseOpt); cmdLineOptions.addOption(dbOpts); cmdLineOptions.addOption(configOpt); cmdLineOptions.addOptionGroup(optGroup); }
From source file:org.apache.sentry.cli.tools.SentryShellCommon.java
protected OptionGroup getMainOptions() { OptionGroup simpleShellOptGroup = new OptionGroup(); Option crOpt = new Option("cr", "create_role", false, "Create role"); crOpt.setRequired(false);/* w ww.j a v a 2 s . co m*/ Option drOpt = new Option("dr", "drop_role", false, "Drop role"); drOpt.setRequired(false); Option argOpt = new Option("arg", "add_role_group", false, "Add role to group"); argOpt.setRequired(false); Option drgOpt = new Option("drg", "delete_role_group", false, "Delete role from group"); drgOpt.setRequired(false); Option gprOpt = new Option("gpr", "grant_privilege_role", false, "Grant privilege to role"); gprOpt.setRequired(false); Option rprOpt = new Option("rpr", "revoke_privilege_role", false, "Revoke privilege from role"); rprOpt.setRequired(false); Option lrOpt = new Option("lr", "list_role", false, "List role"); lrOpt.setRequired(false); Option lpOpt = new Option("lp", "list_privilege", false, "List privilege"); lpOpt.setRequired(false); Option lgOpt = new Option("lg", "list_group", false, "List groups"); lgOpt.setRequired(false); // required args group simpleShellOptGroup.addOption(crOpt); simpleShellOptGroup.addOption(drOpt); simpleShellOptGroup.addOption(argOpt); simpleShellOptGroup.addOption(drgOpt); simpleShellOptGroup.addOption(gprOpt); simpleShellOptGroup.addOption(rprOpt); simpleShellOptGroup.addOption(lrOpt); simpleShellOptGroup.addOption(lpOpt); simpleShellOptGroup.addOption(lgOpt); simpleShellOptGroup.setRequired(true); return simpleShellOptGroup; }
From source file:org.apache.sentry.provider.db.tools.SentrySchemaTool.java
@SuppressWarnings("static-access") private static void initOptions(Options cmdLineOptions) { Option help = new Option("help", "print this message"); Option upgradeOpt = new Option("upgradeSchema", "Schema upgrade"); Option upgradeFromOpt = OptionBuilder.withArgName("upgradeFrom").hasArg() .withDescription("Schema upgrade from a version").create("upgradeSchemaFrom"); Option initOpt = new Option("initSchema", "Schema initialization"); Option initToOpt = OptionBuilder.withArgName("initTo").hasArg() .withDescription("Schema initialization to a version").create("initSchemaTo"); Option infoOpt = new Option("info", "Show config and schema details"); OptionGroup optGroup = new OptionGroup(); optGroup.addOption(upgradeOpt).addOption(initOpt).addOption(help).addOption(upgradeFromOpt) .addOption(initToOpt).addOption(infoOpt); optGroup.setRequired(true);/*from ww w . j a v a2s . co m*/ Option userNameOpt = OptionBuilder.withArgName("user").hasArg() .withDescription("Override config file user name").create("userName"); Option passwdOpt = OptionBuilder.withArgName("password").hasArg() .withDescription("Override config file password").create("passWord"); Option dbTypeOpt = OptionBuilder.withArgName("databaseType").hasArg() .withDescription("Metastore database type [" + SentrySchemaHelper.DB_DERBY + "," + SentrySchemaHelper.DB_MYSQL + "," + SentrySchemaHelper.DB_ORACLE + "," + SentrySchemaHelper.DB_POSTGRACE + "," + SentrySchemaHelper.DB_DB2 + "]") .create("dbType"); Option dbOpts = OptionBuilder.withArgName("databaseOpts").hasArgs() .withDescription("Backend DB specific options").create("dbOpts"); Option dryRunOpt = new Option("dryRun", "list SQL scripts (no execute)"); Option verboseOpt = new Option("verbose", "only print SQL statements"); Option configOpt = OptionBuilder.withArgName("confName").hasArgs() .withDescription("Sentry Service configuration file").isRequired(true) .create(ServiceConstants.ServiceArgs.CONFIG_FILE_LONG); cmdLineOptions.addOption(help); cmdLineOptions.addOption(dryRunOpt); cmdLineOptions.addOption(userNameOpt); cmdLineOptions.addOption(passwdOpt); cmdLineOptions.addOption(dbTypeOpt); cmdLineOptions.addOption(verboseOpt); cmdLineOptions.addOption(dbOpts); cmdLineOptions.addOption(configOpt); cmdLineOptions.addOptionGroup(optGroup); }
From source file:org.apache.sentry.provider.db.tools.SentryShellCommon.java
/** * parse arguments//w ww.j a v a 2 s . c o m * * <pre> * -conf,--sentry_conf <filepath> sentry config file path * -cr,--create_role -r <rolename> create role * -dr,--drop_role -r <rolename> drop role * -arg,--add_role_group -r <rolename> -g <groupname> add role to group * -drg,--delete_role_group -r <rolename> -g <groupname> delete role from group * -gpr,--grant_privilege_role -r <rolename> -p <privilege> grant privilege to role * -rpr,--revoke_privilege_role -r <rolename> -p <privilege> revoke privilege from role * -lr,--list_role -g <groupname> list roles for group * -lp,--list_privilege -r <rolename> list privilege for role * -t,--type <typeame> the shell for hive model or generic model * </pre> * * @param args */ protected boolean parseArgs(String[] args) { Options simpleShellOptions = new Options(); Option crOpt = new Option("cr", "create_role", false, "Create role"); crOpt.setRequired(false); Option drOpt = new Option("dr", "drop_role", false, "Drop role"); drOpt.setRequired(false); Option argOpt = new Option("arg", "add_role_group", false, "Add role to group"); argOpt.setRequired(false); Option drgOpt = new Option("drg", "delete_role_group", false, "Delete role from group"); drgOpt.setRequired(false); Option gprOpt = new Option("gpr", "grant_privilege_role", false, "Grant privilege to role"); gprOpt.setRequired(false); Option rprOpt = new Option("rpr", "revoke_privilege_role", false, "Revoke privilege from role"); rprOpt.setRequired(false); Option lrOpt = new Option("lr", "list_role", false, "List role"); lrOpt.setRequired(false); Option lpOpt = new Option("lp", "list_privilege", false, "List privilege"); lpOpt.setRequired(false); // required args group OptionGroup simpleShellOptGroup = new OptionGroup(); simpleShellOptGroup.addOption(crOpt); simpleShellOptGroup.addOption(drOpt); simpleShellOptGroup.addOption(argOpt); simpleShellOptGroup.addOption(drgOpt); simpleShellOptGroup.addOption(gprOpt); simpleShellOptGroup.addOption(rprOpt); simpleShellOptGroup.addOption(lrOpt); simpleShellOptGroup.addOption(lpOpt); simpleShellOptGroup.setRequired(true); simpleShellOptions.addOptionGroup(simpleShellOptGroup); // optional args Option pOpt = new Option("p", "privilege", true, OPTION_DESC_PRIVILEGE); pOpt.setRequired(false); simpleShellOptions.addOption(pOpt); Option gOpt = new Option("g", "groupname", true, OPTION_DESC_GROUP_NAME); gOpt.setRequired(false); simpleShellOptions.addOption(gOpt); Option rOpt = new Option("r", "rolename", true, OPTION_DESC_ROLE_NAME); rOpt.setRequired(false); simpleShellOptions.addOption(rOpt); // this argument should be parsed in the bin/sentryShell Option tOpt = new Option("t", "type", true, "[hive|solr|sqoop|.....]"); tOpt.setRequired(false); simpleShellOptions.addOption(tOpt); // file path of sentry-site Option sentrySitePathOpt = new Option("conf", "sentry_conf", true, OPTION_DESC_CONF); sentrySitePathOpt.setRequired(true); simpleShellOptions.addOption(sentrySitePathOpt); // help option Option helpOpt = new Option("h", "help", false, OPTION_DESC_HELP); helpOpt.setRequired(false); simpleShellOptions.addOption(helpOpt); // this Options is parsed first for help option Options helpOptions = new Options(); helpOptions.addOption(helpOpt); try { Parser parser = new GnuParser(); // parse help option first CommandLine cmd = parser.parse(helpOptions, args, true); for (Option opt : cmd.getOptions()) { if (opt.getOpt().equals("h")) { // get the help option, print the usage and exit usage(simpleShellOptions); return false; } } // without help option cmd = parser.parse(simpleShellOptions, args); for (Option opt : cmd.getOptions()) { if (opt.getOpt().equals("p")) { privilegeStr = opt.getValue(); } else if (opt.getOpt().equals("g")) { groupName = opt.getValue(); } else if (opt.getOpt().equals("r")) { roleName = opt.getValue(); } else if (opt.getOpt().equals("cr")) { isCreateRole = true; roleNameRequired = true; } else if (opt.getOpt().equals("dr")) { isDropRole = true; roleNameRequired = true; } else if (opt.getOpt().equals("arg")) { isAddRoleGroup = true; roleNameRequired = true; groupNameRequired = true; } else if (opt.getOpt().equals("drg")) { isDeleteRoleGroup = true; roleNameRequired = true; groupNameRequired = true; } else if (opt.getOpt().equals("gpr")) { isGrantPrivilegeRole = true; roleNameRequired = true; privilegeStrRequired = true; } else if (opt.getOpt().equals("rpr")) { isRevokePrivilegeRole = true; roleNameRequired = true; privilegeStrRequired = true; } else if (opt.getOpt().equals("lr")) { isListRole = true; } else if (opt.getOpt().equals("lp")) { isListPrivilege = true; roleNameRequired = true; } else if (opt.getOpt().equals("conf")) { confPath = opt.getValue(); } } checkRequiredParameter(roleNameRequired, roleName, OPTION_DESC_ROLE_NAME); checkRequiredParameter(groupNameRequired, groupName, OPTION_DESC_GROUP_NAME); checkRequiredParameter(privilegeStrRequired, privilegeStr, OPTION_DESC_PRIVILEGE); } catch (ParseException pe) { System.out.println(pe.getMessage()); usage(simpleShellOptions); return false; } return true; }
From source file:org.apache.sysml.conf.DMLOptions.java
@SuppressWarnings("static-access") private static Options createCLIOptions() { Options options = new Options(); Option nvargsOpt = OptionBuilder.withArgName("key=value").withDescription( "parameterizes DML script with named parameters of the form <key=value>; <key> should be a valid identifier in DML/PyDML") .hasArgs().create("nvargs"); Option argsOpt = OptionBuilder.withArgName("argN").withDescription( "specifies positional parameters; first value will replace $1 in DML program; $2 will replace 2nd and so on") .hasArgs().create("args"); Option configOpt = OptionBuilder.withArgName("filename").withDescription( "uses a given configuration file (can be on local/hdfs/gpfs; default values in SystemML-config.xml") .hasArg().create("config"); Option cleanOpt = OptionBuilder.withDescription( "cleans up all SystemML working directories (FS, DFS); all other flags are ignored in this mode. \n") .create("clean"); Option statsOpt = OptionBuilder.withArgName("count").withDescription( "monitors and reports summary execution statistics; heavy hitter <count> is 10 unless overridden; default off") .hasOptionalArg().create("stats"); Option memOpt = OptionBuilder .withDescription("monitors and reports max memory consumption in CP; default off").create("mem"); Option explainOpt = OptionBuilder.withArgName("level").withDescription( "explains plan levels; can be 'hops' / 'runtime'[default] / 'recompile_hops' / 'recompile_runtime'") .hasOptionalArg().create("explain"); Option execOpt = OptionBuilder.withArgName("mode").withDescription( "sets execution mode; can be 'hadoop' / 'singlenode' / 'hybrid'[default] / 'hybrid_spark' / 'spark'") .hasArg().create("exec"); Option gpuOpt = OptionBuilder.withArgName("force").withDescription( "uses CUDA instructions when reasonable; set <force> option to skip conservative memory estimates and use GPU wherever possible; default off") .hasOptionalArg().create("gpu"); Option debugOpt = OptionBuilder.withDescription("runs in debug mode; default off").create("debug"); Option pythonOpt = OptionBuilder.withDescription("parses Python-like DML").create("python"); Option fileOpt = OptionBuilder.withArgName("filename").withDescription( "specifies dml/pydml file to execute; path can be local/hdfs/gpfs (prefixed with appropriate URI)") .isRequired().hasArg().create("f"); Option scriptOpt = OptionBuilder.withArgName("script_contents") .withDescription("specified script string to execute directly").isRequired().hasArg().create("s"); Option helpOpt = OptionBuilder.withDescription("shows usage message").create("help"); options.addOption(configOpt);// ww w . j a v a 2 s.co m options.addOption(cleanOpt); options.addOption(statsOpt); options.addOption(memOpt); options.addOption(explainOpt); options.addOption(execOpt); options.addOption(gpuOpt); options.addOption(debugOpt); options.addOption(pythonOpt); // Either a clean(-clean), a file(-f), a script(-s) or help(-help) needs to be specified OptionGroup fileOrScriptOpt = new OptionGroup().addOption(scriptOpt).addOption(fileOpt).addOption(cleanOpt) .addOption(helpOpt); fileOrScriptOpt.setRequired(true); options.addOptionGroup(fileOrScriptOpt); // Either -args or -nvargs options.addOptionGroup(new OptionGroup().addOption(nvargsOpt).addOption(argsOpt)); options.addOption(helpOpt); return options; }
From source file:org.apache.tomcat.vault.VaultTool.java
/** * Build options for non-interactive VaultTool usage scenario. * * @return/*w w w . j a v a2 s . c o m*/ */ private void initOptions() { options = new Options(); options.addOption("k", KEYSTORE_PARAM, true, "Keystore URL"); options.addOption("p", KEYSTORE_PASSWORD_PARAM, true, "Keystore password"); options.addOption("e", ENC_DIR_PARAM, true, "Directory containing encrypted files"); options.addOption("s", SALT_PARAM, true, "8 character salt"); options.addOption("i", ITERATION_PARAM, true, "Iteration count"); options.addOption("A", ALIAS_PARAM, true, "Vault keystore alias"); options.addOption("b", VAULT_BLOCK_PARAM, true, "Vault block"); options.addOption("a", ATTRIBUTE_PARAM, true, "Attribute name"); OptionGroup og = new OptionGroup(); Option x = new Option("x", SEC_ATTR_VALUE_PARAM, true, "Secured attribute value (such as password) to store"); Option c = new Option("c", CHECK_SEC_ATTR_EXISTS_PARAM, false, "Check whether the secured attribute already exists in the vault"); Option r = new Option("r", REMOVE_SEC_ATTR, false, "Remove the secured attribute from the vault"); Option g = new Option("g", GENERATE_CONFIG_FILE, true, "Path for generated config file"); Option h = new Option("h", HELP_PARAM, false, "Help"); Option E = new Option("E", CRYPT, false, "Encrypt value using CRYPT feature"); og.addOption(x); og.addOption(c); og.addOption(r); og.addOption(g); og.addOption(h); og.addOption(E); og.setRequired(true); options.addOptionGroup(og); }
From source file:org.apache.tuscany.sca.node.equinox.launcher.NodeMain.java
public static void main(String[] args) throws Exception { CommandLineParser parser = new PosixParser(); Options options = new Options(); OptionGroup group = new OptionGroup(); group.addOption(new Option("dm", "domainManager", false, "Domain Manager")); group.addOption(new Option("nd", "nodeDaemon", false, "Node Domain")); options.addOptionGroup(group);//from ww w . ja v a 2s .co m // Add options from NodeLauncher to avoid UnrecognizedOptionException for (Object o : NodeLauncher.getCommandLineOptions().getOptions()) { options.addOption((Option) o); } CommandLine cli = parser.parse(options, args); if (cli.hasOption("nd")) { NodeDaemonLauncher.main(args); } else if (cli.hasOption("dm")) { DomainManagerLauncher.main(args); } else { NodeLauncher.main(args); } }