List of usage examples for org.apache.commons.cli OptionGroup setRequired
public void setRequired(boolean required)
From source file:eu.itesla_project.online.tools.OnlineWorkflowCommand.java
@Override public Options getOptions() { Options opts = new Options(); OptionGroup og = new OptionGroup(); og.setRequired(true); og.addOption(Option.builder().longOpt(START_CMD).desc("start new online workflow").build()); og.addOption(Option.builder().longOpt(SHUTDOWN_CMD).desc("shutdown online workflow application").build()); opts.addOptionGroup(og);/*from ww w. ja v a2 s . c o m*/ opts.addOption(Option.builder().longOpt(HOST).desc("jmx host").hasArg().argName("HOST").build()); opts.addOption(Option.builder().longOpt(PORT).desc("jmx port").hasArg().argName("PORT").build()); opts.addOption(Option.builder().longOpt(BASE_CASE).desc("Base case").hasArg().argName(BASE_CASE).build()); opts.addOption(Option.builder().longOpt(TIME_HORIZON).desc("time horizon for the online analysis").hasArg() .argName(TIME_HORIZON).build()); opts.addOption(Option.builder().longOpt(BASE_CASE).desc("Basecase to be analyzed").hasArg() .argName(BASE_CASE).build()); opts.addOption(Option.builder().longOpt(STATES).desc("States number").hasArg().argName(STATES).build()); opts.addOption( Option.builder().longOpt(WORKFLOW_ID).desc("offline workflow id that produced the security rules") .hasArg().argName(WORKFLOW_ID).build()); opts.addOption(Option.builder().longOpt(HISTODB_INTERVAL) .desc("interval of historical data to be used for WCA").hasArg().argName(HISTODB_INTERVAL).build()); opts.addOption(Option.builder().longOpt(THREADS).desc("Executing threads number").hasArg().argName(THREADS) .build()); opts.addOption(Option.builder().longOpt(FEANALYSIS_ID).desc("id of the forecast error analysis").hasArg() .argName(FEANALYSIS_ID).build()); opts.addOption(Option.builder().longOpt(RULES_PURITY).desc("purity threshold for the security rules") .hasArg().argName(RULES_PURITY).build()); opts.addOption(Option.builder().longOpt(STORE_STATES).desc("store states").build()); opts.addOption(Option.builder().longOpt(ANALYSE_BASECASE).desc("analyse basecase").build()); opts.addOption(Option.builder().longOpt(VALIDATION).desc("validation").build()); opts.addOption(Option.builder().longOpt(SECURITY_INDEXES) .desc("sub list of security index types to use, use ALL for using all of them").hasArg() .argName("INDEX_TYPE,INDEX_TYPE,...").build()); opts.addOption(Option.builder().longOpt(BASECASES_INTERVAL) .desc("interval for basecases to be considered; when set, overrides base-case parameter").hasArg() .argName(BASECASES_INTERVAL).build()); opts.addOption(Option.builder().longOpt(CASE_TYPE).desc("the type (FO/SN) of the base case").hasArg() .argName(CASE_TYPE).build()); opts.addOption( Option.builder().longOpt(COUNTRIES).desc("the countries of the base case, separated by comma") .hasArg().argName("COUNTRY,COUNTRY,...").build()); opts.addOption(Option.builder().longOpt(MERGE_OPTIMIZED).desc("merge optimized").build()); opts.addOption(Option.builder().longOpt(LIMIT_REDUCTION).desc("limits reduction").hasArg() .argName(LIMIT_REDUCTION).build()); opts.addOption(Option.builder().longOpt(HANDLE_VIOLATION_IN_N).desc("handle violation in n").build()); opts.addOption(Option.builder().longOpt(CONSTRAINT_MARGIN).desc("constraint margin").hasArg() .argName(CONSTRAINT_MARGIN).build()); opts.addOption(Option.builder().longOpt(CASE_FILE) .desc("case file: Note: parameter " + CASE_FILE + "cannot be used together with parameters " + BASE_CASE + ", " + CASE_TYPE + ", " + COUNTRIES + ", " + BASECASES_INTERVAL) .hasArg().argName(CASE_FILE).build()); return opts; }
From source file:com.netspective.sparx.security.authenticator.SingleUserServletLoginAuthenticator.java
private Options createAuthenticatorOptions() { Options authenticatorOptions = new Options(); authenticatorOptions.addOption(/*from w ww . j a va 2s . com*/ OptionBuilder.withLongOpt("help").withDescription("Print options to stdout").create('?')); authenticatorOptions.addOption(OptionBuilder.withLongOpt("user-id").hasArg().withArgName("id") .withDescription("The user id that should be used to log the user in").isRequired().create('u')); authenticatorOptions.addOption(OptionBuilder.withLongOpt("show-encrypted-password") .withDescription("Prints the encrypted version of plain-text password to stdout").create('s')); OptionGroup passwordOptionGroup = new OptionGroup(); passwordOptionGroup.setRequired(true); passwordOptionGroup.addOption(OptionBuilder.withLongOpt("plain-text-password").hasArg() .withArgName("plain-text").withDescription("The plain-text password for the user").create('p')); passwordOptionGroup.addOption(OptionBuilder.withLongOpt("encrypted-password").hasArg() .withArgName("encrypted-text").withDescription("The encrypted password for the user").create('P')); authenticatorOptions.addOptionGroup(passwordOptionGroup); return authenticatorOptions; }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.sensitivity.ExtractData.java
@SuppressWarnings("static-access") @Override//w w w .j av a 2 s.co m public Options getOptions() { Options options = super.getOptions(); OptionGroup group = new OptionGroup(); group.setRequired(true); group.addOption(OptionBuilder.withLongOpt("problem").hasArg().withArgName("name").create('b')); group.addOption(OptionBuilder.withLongOpt("dimension").hasArg().withArgName("number").create('d')); options.addOptionGroup(group); options.addOption(OptionBuilder.withLongOpt("input").hasArg().withArgName("file").isRequired().create('i')); options.addOption(OptionBuilder.withLongOpt("output").hasArg().withArgName("file").create('o')); options.addOption(OptionBuilder.withLongOpt("separator").hasArg().withArgName("value").create('s')); options.addOption(OptionBuilder.withLongOpt("reference").hasArg().withArgName("file").create('r')); options.addOption(OptionBuilder.withLongOpt("epsilon").hasArg().withArgName("e1,e2,...").create('e')); options.addOption(OptionBuilder.withLongOpt("noheader").create('n')); return options; }
From source file:com.opengamma.integration.tool.portfolio.PortfolioDeleteTool.java
@Override protected Options createOptions(boolean contextProvided) { Options options = super.createOptions(contextProvided); Option portfolioNamesOption = new Option(PORTFOLIO_NAMES_OPT, "name", true, "Regular expression to match portfolio names"); // options.addOption(portfolioNamesOption); Option deletePortfolioIdsOption = new Option(PORTFOLIO_IDS_OPT, "portfolioid", true, "Portfolio IDs to match"); // options.addOption(deletePortfolioIdsOption); OptionGroup group = new OptionGroup(); group.addOption(deletePortfolioIdsOption); group.addOption(portfolioNamesOption); group.setRequired(true); options.addOptionGroup(group);/*from w w w .jav a 2 s . com*/ Option deletePositionsOption = new Option(DELETE_POSITIONS_OPT, "delpositions", false, "Match/delete positions referenced in matching portfolios"); options.addOption(deletePositionsOption); Option deleteSecuritiesOption = new Option(DELETE_SECURITIES_OPT, "delsecurities", false, "Match/delete securities referenced in matching portfolios"); options.addOption(deleteSecuritiesOption); Option deletePortfoliosOption = new Option(DELETE_PORTFOLIOS_OPT, "delportfolios", false, "Actually delete matching portfolios"); options.addOption(deletePortfoliosOption); Option writeOption = new Option(WRITE_OPT, "write", false, "Actually persist the deletions"); options.addOption(writeOption); Option verboseOption = new Option(VERBOSE_OPT, "verbose", false, "Displays progress messages on the terminal"); options.addOption(verboseOption); return options; }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.tools.AerovisConverter.java
@SuppressWarnings("static-access") @Override//from w w w .ja va 2s .c o m public Options getOptions() { Options options = super.getOptions(); OptionGroup group = new OptionGroup(); group.setRequired(true); group.addOption(OptionBuilder.withLongOpt("problem").hasArg().withArgName("name").create('b')); group.addOption(OptionBuilder.withLongOpt("dimension").hasArg().withArgName("number").create('d')); options.addOptionGroup(group); options.addOption(OptionBuilder.withLongOpt("input").hasArg().withArgName("file").isRequired().create('i')); options.addOption( OptionBuilder.withLongOpt("output").hasArg().withArgName("file").isRequired().create('o')); options.addOption(OptionBuilder.withLongOpt("reduced").create('r')); options.addOption(OptionBuilder.withLongOpt("names").hasArg().create('n')); return options; }
From source file:de.thetaphi.forbiddenapis.cli.CliMain.java
public CliMain(String... args) throws ExitException { final OptionGroup required = new OptionGroup(); required.setRequired(true); required.addOption(dirOpt = Option.builder("d").desc( "directory with class files to check for forbidden api usage; this directory is also added to classpath") .longOpt("dir").hasArg().argName("directory").build()); required.addOption(// w w w. jav a 2 s. com versionOpt = Option.builder("V").desc("print product version and exit").longOpt("version").build()); required.addOption(helpOpt = Option.builder("h").desc("print this help").longOpt("help").build()); final Options options = new Options(); options.addOptionGroup(required); options.addOption(classpathOpt = Option.builder("c") .desc("class search path of directories and zip/jar files").longOpt("classpath").hasArgs() .valueSeparator(File.pathSeparatorChar).argName("path").build()); options.addOption(includesOpt = Option.builder("i").desc( "ANT-style pattern to select class files (separated by commas or option can be given multiple times, defaults to '**/*.class')") .longOpt("includes").hasArgs().valueSeparator(',').argName("pattern").build()); options.addOption(excludesOpt = Option.builder("e").desc( "ANT-style pattern to exclude some files from checks (separated by commas or option can be given multiple times)") .longOpt("excludes").hasArgs().valueSeparator(',').argName("pattern").build()); options.addOption(signaturesfileOpt = Option.builder("f") .desc("path to a file containing signatures (option can be given multiple times)") .longOpt("signaturesfile").hasArg().argName("file").build()); options.addOption(bundledsignaturesOpt = Option.builder("b").desc( "name of a bundled signatures definition (separated by commas or option can be given multiple times)") .longOpt("bundledsignatures").hasArgs().valueSeparator(',').argName("name").build()); options.addOption(suppressannotationsOpt = Option.builder().desc( "class name or glob pattern of annotation that suppresses error reporting in classes/methods/fields (separated by commas or option can be given multiple times)") .longOpt("suppressannotation").hasArgs().valueSeparator(',').argName("classname").build()); options.addOption(internalruntimeforbiddenOpt = Option.builder().desc(String.format(Locale.ENGLISH, "DEPRECATED: forbids calls to non-portable runtime APIs; use bundled signatures '%s' instead", BS_JDK_NONPORTABLE)).longOpt("internalruntimeforbidden").build()); options.addOption(allowmissingclassesOpt = Option.builder() .desc("don't fail if a referenced class is missing on classpath").longOpt("allowmissingclasses") .build()); options.addOption(allowunresolvablesignaturesOpt = Option.builder() .desc("don't fail if a signature is not resolving").longOpt("allowunresolvablesignatures").build()); try { this.cmd = new DefaultParser().parse(options, args); if (cmd.hasOption(helpOpt.getLongOpt())) { printHelp(options); throw new ExitException(EXIT_SUCCESS); } if (cmd.hasOption(versionOpt.getLongOpt())) { printVersion(); throw new ExitException(EXIT_SUCCESS); } } catch (org.apache.commons.cli.ParseException pe) { printHelp(options); throw new ExitException(EXIT_ERR_CMDLINE); } }
From source file:de.thetaphi.forbiddenapis.CliMain.java
@SuppressWarnings({ "static-access", "static" }) public CliMain(String... args) throws ExitException { final OptionGroup required = new OptionGroup(); required.setRequired(true); required.addOption(dirOpt = OptionBuilder.withDescription( "directory with class files to check for forbidden api usage; this directory is also added to classpath") .withLongOpt("dir").hasArg().withArgName("directory").create('d')); required.addOption(versionOpt = OptionBuilder.withDescription("print product version and exit") .withLongOpt("version").create('V')); required.addOption(/*from ww w . j a va2 s . c o m*/ helpOpt = OptionBuilder.withDescription("print this help").withLongOpt("help").create('h')); final Options options = new Options(); options.addOptionGroup(required); options.addOption(classpathOpt = OptionBuilder .withDescription("class search path of directories and zip/jar files").withLongOpt("classpath") .hasArgs().withValueSeparator(File.pathSeparatorChar).withArgName("path").create('c')); options.addOption(includesOpt = OptionBuilder.withDescription( "ANT-style pattern to select class files (separated by commas or option can be given multiple times, defaults to '**/*.class')") .withLongOpt("includes").hasArgs().withValueSeparator(',').withArgName("pattern").create('i')); options.addOption(excludesOpt = OptionBuilder.withDescription( "ANT-style pattern to exclude some files from checks (separated by commas or option can be given multiple times)") .withLongOpt("excludes").hasArgs().withValueSeparator(',').withArgName("pattern").create('e')); options.addOption(signaturesfileOpt = OptionBuilder .withDescription("path to a file containing signatures (option can be given multiple times)") .withLongOpt("signaturesfile").hasArg().withArgName("file").create('f')); options.addOption(bundledsignaturesOpt = OptionBuilder.withDescription( "name of a bundled signatures definition (separated by commas or option can be given multiple times)") .withLongOpt("bundledsignatures").hasArgs().withValueSeparator(',').withArgName("name") .create('b')); options.addOption(suppressannotationsOpt = OptionBuilder.withDescription( "class name or glob pattern of annotation that suppresses error reporting in classes/methods/fields (separated by commas or option can be given multiple times)") .withLongOpt("suppressannotation").hasArgs().withValueSeparator(',').withArgName("classname") .create()); options.addOption(internalruntimeforbiddenOpt = OptionBuilder .withDescription("forbids calls to classes from the internal java runtime (like sun.misc.Unsafe)") .withLongOpt("internalruntimeforbidden").create()); options.addOption(allowmissingclassesOpt = OptionBuilder .withDescription("don't fail if a referenced class is missing on classpath") .withLongOpt("allowmissingclasses").create()); options.addOption(allowunresolvablesignaturesOpt = OptionBuilder .withDescription("don't fail if a signature is not resolving") .withLongOpt("allowunresolvablesignatures").create()); try { this.cmd = new PosixParser().parse(options, args); if (cmd.hasOption(helpOpt.getLongOpt())) { printHelp(options); throw new ExitException(EXIT_SUCCESS); } if (cmd.hasOption(versionOpt.getLongOpt())) { printVersion(); throw new ExitException(EXIT_SUCCESS); } } catch (org.apache.commons.cli.ParseException pe) { printHelp(options); throw new ExitException(EXIT_ERR_CMDLINE); } }
From source file:ditl.transfers.cli.AnalyzeTransfers.java
@Override protected void initOptions() { super.initOptions(); options.addOption(null, messagesOption, true, "name of messages trace"); options.addOption(null, buffersOption, true, "name of buffer trace"); options.addOption(null, transfersOption, true, "name of transfers trace"); options.addOption(null, minTimeOption, true, "time to begin analysis"); options.addOption(null, maxTimeOption, true, "time to end analysis"); final OptionGroup reportGroup = new OptionGroup(); reportGroup.addOption(new Option(null, broadcastDeliveryOption, false, "broadcast delivery report")); reportGroup.addOption(new Option(null, messageTransferOption, false, "message transfers report")); reportGroup.setRequired(true); options.addOptionGroup(reportGroup); }
From source file:net.nharyes.drivecopy.Main.java
private void composeOptions() { // file option Option file = OptionBuilder.create('f'); file.setLongOpt("file"); file.setArgs(1);//w w w . j a v a 2 s . c o m file.setArgName("path"); file.setDescription("where path is the file to upload/download/replace."); // directory option Option directory = OptionBuilder.create('d'); directory.setLongOpt("directory"); directory.setArgs(1); directory.setArgName("path"); directory.setDescription( "where path is the local directory to upload/download/replace (it will be archived into a single remote file)."); // file and directory group OptionGroup group = new OptionGroup(); group.addOption(file); group.addOption(directory); group.setRequired(true); options.addOptionGroup(group); // compression level option Option level = OptionBuilder.create('l'); level.setLongOpt("level"); level.setArgs(1); level.setArgName("num"); level.setOptionalArg(true); level.setType(Integer.class); level.setDescription( "where num is the compression level from 0 to 9. Used when uploading/replacing directories. The default value is 0."); options.addOption(level); // delete option Option delete = OptionBuilder.create('D'); delete.setLongOpt("delete"); delete.setOptionalArg(true); delete.setType(Boolean.class); delete.setDescription("delete local file/directory after remote entry uploaded/replaced."); options.addOption(delete); // log option Option log = OptionBuilder.create('L'); log.setLongOpt("log"); log.setArgs(1); log.setArgName("file"); log.setType(String.class); log.setDescription("where file is the log file to write"); options.addOption(log); // MIME type option Option mimeType = OptionBuilder.create('m'); mimeType.setLongOpt("mimetype"); mimeType.setArgs(1); mimeType.setArgName("type"); mimeType.setType(String.class); mimeType.setDescription( "where type is the MIME type string to set for the remote entry. The default values are 'application/octet-stream' for files and 'application/zip' for compressed directories."); options.addOption(mimeType); // skip revision option Option skipRevision = OptionBuilder.create('s'); skipRevision.setLongOpt("skiprevision"); skipRevision.setOptionalArg(true); skipRevision.setType(Boolean.class); skipRevision.setDescription("do not create a new revision when replacing remote entry."); options.addOption(skipRevision); // check MD5 option Option checkMd5 = OptionBuilder.create('c'); checkMd5.setLongOpt("checkmd5"); checkMd5.setOptionalArg(true); checkMd5.setType(Boolean.class); checkMd5.setDescription( "compare uploaded/downloaded local file MD5 summary with the one of the remote entry."); options.addOption(checkMd5); // check force creation option Option forceCreation = OptionBuilder.create('F'); forceCreation.setLongOpt("force"); forceCreation.setOptionalArg(true); forceCreation.setType(Boolean.class); forceCreation.setDescription( "forces the creation of the remote entry when replace is selected and the entry doesn't exist."); options.addOption(forceCreation); // settings file option Option settings = OptionBuilder.create('C'); settings.setLongOpt("configuration"); settings.setArgs(1); settings.setArgName("path"); settings.setType(String.class); settings.setDescription(String.format( "where path is the path of the configuration file. The default value is '%s' in the same directory.", CONFIGURATION_FILE)); options.addOption(settings); // create folders tree option Option tree = OptionBuilder.create('t'); tree.setLongOpt("tree"); tree.setOptionalArg(true); tree.setType(Boolean.class); tree.setDescription("create remote folders tree if one or more remote folders are not found."); options.addOption(tree); }
From source file:edu.psu.cse.siis.coal.CommandLineParser.java
/** * Populates the default command line arguments that are common to all analyses. * //from w w w . ja v a 2s . c om * @param options The command line options object that should be modified. */ private void parseDefaultCommandLineArguments(Options options) { OptionGroup modelGroup = new OptionGroup(); modelGroup.addOption(Option.builder("model").desc("Path to the model directory.").hasArg() .argName("model directory").build()); modelGroup.addOption(Option.builder("cmodel").desc("Path to the compiled model.").hasArg() .argName("compiled model").build()); modelGroup.setRequired(false); options.addOptionGroup(modelGroup); options.addOption(Option.builder("cp").desc("The classpath for the analysis.").hasArg().argName("classpath") .required().longOpt("classpath").build()); options.addOption(Option.builder("in").desc("The input code for the analysis.").hasArg().argName("input") .required().longOpt("input").build()); options.addOption(Option.builder("out").desc("The output directory or file.").hasArg().argName("output") .longOpt("output").build()); options.addOption( Option.builder("traversemodeled").desc("Propagate through modeled classes.").hasArg(false).build()); options.addOption("modeledtypesonly", false, "Only infer modeled types."); options.addOption(Option.builder("threadcount").desc("The maximum number of threads that should be used.") .hasArg().argName("thread count").type(Number.class).build()); }