List of usage examples for org.apache.commons.cli OptionGroup setRequired
public void setRequired(boolean required)
From source file:fr.iphc.grid.jobmanager.JobManager.java
@SuppressWarnings("static-access") protected Options createOptions() { Options opt = new Options(); // command//from w w w .ja v a 2 s. c o m opt.addOption(OptionBuilder.withDescription("Display this help and exit").withLongOpt(LONGOPT_HELP) .create(OPT_HELP)); // optional arguments opt.addOption(OptionBuilder.withDescription("file with cream URL [IPHC]").hasArg() .withLongOpt(LONGOPT_QUEUE).withArgName("queue").create(OPT_QUEUE)); opt.addOption(OptionBuilder .withDescription("generate the job description in the targeted grid language " + "and exit (do not submit the job)") .withLongOpt(LONGOPT_DESCRIPTION).create(OPT_DESCRIPTION)); opt.addOption(OptionBuilder.withDescription("File List of Bad Ce elminate from the Ce List[IPHC]").hasArg() .withLongOpt(LONGOPT_BAD).create(OPT_BAD)); opt.addOption(OptionBuilder .withDescription("Time -> END Program in minutes/hour (Default 10H) Value: mM hH [IPHC]").hasArg() .withLongOpt(LONGOPT_END).create(OPT_END)); opt.addOption(OptionBuilder .withDescription("Duration Run -Thread in minutes/hour (Default 1H) Value: mM hH [IPHC]").hasArg() .withLongOpt(LONGOPT_RUN).create(OPT_RUN)); opt.addOption( OptionBuilder.withDescription("Time queue wating in CE/queue in minutes (Default 15 mn) [IPHC]") .hasArg().withLongOpt(LONGOPT_WAIT).create(OPT_WAIT)); opt.addOption(OptionBuilder.withDescription("Threshold display full log in log file[IPHC]").hasArg() .withLongOpt(LONGOPT_LOGDISPLAY).create(OPT_LOGDISPLAY)); opt.addOption( OptionBuilder.withDescription("Define working directory for monitoring file (default cwd) [IPHC]") .hasArg().withLongOpt(LONGOPT_CWD).create(OPT_CWD)); opt.addOption(OptionBuilder.withDescription("Setup xml file Global paramters (default setup) [IPHC]") .hasArg().withLongOpt(LONGOPT_SETUP).create(OPT_SETUP)); opt.addOption(OptionBuilder.withDescription("Disable Optimize Timeout Run Average execution time[IPHC]") .withLongOpt(LONGOPT_OPTIMIZETIMEOUTRUN).create(OPT_OPTIMIZETIMEOUTRUN)); // required arguments group jdl file | list of jdl OptionGroup reqGroup = new OptionGroup(); reqGroup.addOption(OptionBuilder.withDescription("read job description from file <path> [IPHC]").hasArg() .withLongOpt(LONGOPT_JOB).withArgName("file").create(OPT_JOB)); reqGroup.addOption(OptionBuilder.withDescription("read file include jdl file [IPHC]").hasArg() .withLongOpt(LONGOPT_FILEJOB).withArgName("list").create(OPT_FILEJOB)); reqGroup.setRequired(true); opt.addOptionGroup(reqGroup); // optional group OptionGroup optGroup = new OptionGroup(); optGroup.addOption(OptionBuilder .withDescription( "print the job identifier as soon as it is submitted, " + "and wait for it to be finished") .withLongOpt(LONGOPT_JOBID).create(OPT_JOBID)); optGroup.setRequired(false); opt.addOptionGroup(optGroup); // job description opt.addOption(o("positional parameters for the command").hasArgs().create(JobDescription.ARGUMENTS)); opt.addOption(o("SPMD job type and startup mechanism").hasArg().create(JobDescription.SPMDVARIATION)); opt.addOption( o("total number of cpus requested for this job").hasArg().create(JobDescription.TOTALCPUCOUNT)); opt.addOption(o("number of process instances to start").hasArg().create(JobDescription.NUMBEROFPROCESSES)); opt.addOption(o("number of processes to start per host").hasArg().create(JobDescription.PROCESSESPERHOST)); opt.addOption( o("expected number of threads per process").hasArg().create(JobDescription.THREADSPERPROCESS)); opt.addOption(o("set of environment variables for the job").hasArgs().withValueSeparator() .create(JobDescription.ENVIRONMENT)); opt.addOption(o("working directory for the job").hasArg().create(JobDescription.WORKINGDIRECTORY)); opt.addOption(o("run the job in interactive mode").create(JobDescription.INTERACTIVE)); opt.addOption(o("pathname of the standard input file").hasArg().create(JobDescription.INPUT)); opt.addOption(o("pathname of the standard output file").hasArg().create(JobDescription.OUTPUT)); opt.addOption(o("pathname of the standard error file").hasArg().create(JobDescription.ERROR)); opt.addOption(o("a list of file transfer directives").hasArgs().create(JobDescription.FILETRANSFER)); opt.addOption(o("defines if output files get removed after the job finishes").hasArg() .create(JobDescription.CLEANUP)); opt.addOption(o("time at which a job should be scheduled").hasArg().create(JobDescription.JOBSTARTTIME)); opt.addOption(o("hard limit for the total job runtime").hasArg().create(JobDescription.WALLTIMELIMIT)); opt.addOption(o("estimated total number of CPU seconds which the job will require").hasArg() .create(JobDescription.TOTALCPUTIME)); opt.addOption(o("estimated amount of memory the job requires").hasArg() .create(JobDescription.TOTALPHYSICALMEMORY)); opt.addOption(o("compatible processor for job submission").hasArg().create(JobDescription.CPUARCHITECTURE)); opt.addOption(o("compatible operating system for job submission").hasArg() .create(JobDescription.OPERATINGSYSTEMTYPE)); opt.addOption( o("list of host names which are to be considered by the resource manager as candidate targets") .hasArgs().create(JobDescription.CANDIDATEHOSTS)); opt.addOption(o("name of a queue to place the job into").hasArg().create(JobDescription.QUEUE)); opt.addOption(o("name of an account or project name").hasArg().create(JobDescription.JOBPROJECT)); opt.addOption(o("set of endpoints describing where to report").hasArgs().create(JobDescription.JOBCONTACT)); // returns return opt; }
From source file:com.zimbra.cs.volume.VolumeCLI.java
@Override protected void setupCommandLineOptions() { super.setupCommandLineOptions(); Options options = getOptions();//from ww w . j a v a 2 s .c om OptionGroup og = new OptionGroup(); og.addOption(new Option(O_A, "add", false, "Adds a volume.")); og.addOption(new Option(O_D, "delete", false, "Deletes a volume.")); og.addOption(new Option(O_L, "list", false, "Lists volumes.")); og.addOption(new Option(O_E, "edit", false, "Edits a volume.")); og.addOption(new Option(O_DC, "displayCurrent", false, "Displays the current volumes.")); og.addOption(new Option(O_SC, "setCurrent", false, "Sets the current volume.")); og.addOption(new Option(O_TS, "turnOffSecondary", false, "Turns off the current secondary message volume")); og.setRequired(true); options.addOptionGroup(og); options.addOption(O_ID, "id", true, "Volume ID"); options.addOption(O_T, "type", true, "Volume type (primaryMessage, secondaryMessage, or index)"); options.addOption(O_N, "name", true, "volume name"); options.addOption(O_P, "path", true, "Root path"); options.addOption(O_C, "compress", true, "Compress blobs; \"true\" or \"false\""); options.addOption(O_CT, "compressionThreshold", true, "Compression threshold; default 4KB"); options.addOption(SoapCLI.OPT_AUTHTOKEN); options.addOption(SoapCLI.OPT_AUTHTOKENFILE); }
From source file:net.ripe.rpki.validator.cli.CommandLineOptions.java
private void addCommandGroup() { OptionGroup group = new OptionGroup(); Option helpOption = new Option("h", HELP, false, "Show usage information"); group.addOption(helpOption);/*from w ww .java 2s . co m*/ Option versionOption = new Option(null, VERSION, false, "Show version information"); group.addOption(versionOption); Option printOption = new Option("p", PRINT, false, "Show the certificate repository object in a readable format"); group.addOption(printOption); Option talOption = new Option("t", TAL, true, "Trust Anchor Locator (TAL). Can be specified more than once."); talOption.setArgs(Option.UNLIMITED_VALUES); group.addOption(talOption); group.setRequired(true); options.addOptionGroup(group); }
From source file:com.continuent.tungsten.common.security.PasswordManagerCtrl.java
/** * Setup command line options// w w w . j a v a 2 s.co m */ @SuppressWarnings("static-access") private void setupCommandLine() { // --- Options on the command line --- Option help = OptionBuilder.withLongOpt(HELP).withDescription("Displays this message").create(_HELP); Option file = OptionBuilder.withLongOpt(FILE).withArgName("filename").hasArgs() .withDescription("Location of the " + SecurityConf.SECURITY_PROPERTIES_FILE_NAME + " file") .create(_FILE); // Mutually excluding options OptionGroup optionGroup = new OptionGroup(); authenticate = OptionBuilder.withLongOpt(AUTHENTICATE).hasArgs(2).withArgName("username> <password") .withDescription("Authenticates a user with given password").create(_AUTHENTICATE); create = OptionBuilder.withLongOpt(CREATE).hasArgs(2).withArgName("username> <password") .withDescription("Creates or Updates a user").create(_CREATE); Option delete = OptionBuilder.withLongOpt(DELETE).withArgName("username").hasArgs() .withDescription("Deletes a user").create(_DELETE); optionGroup.addOption(authenticate); optionGroup.addOption(create); optionGroup.addOption(delete); optionGroup.setRequired(true); // At least 1 command required Option targetApplication = OptionBuilder.withLongOpt(TARGET_APPLICATION).withArgName("target").hasArgs() .withDescription("Target application: " + getListOfClientApplicationType()) .create(_TARGET_APPLICATION); // --- Options replacing parameters from security.properties --- Option encryptedPassword = OptionBuilder.withLongOpt(ENCRYPTED_PASSWORD).withArgName("encrypt password") .withDescription("Encrypts the password").create(_ENCRYPTED_PASSWORD); Option truststoreLocation = OptionBuilder.withLongOpt(TRUSTSTORE_LOCATION).withArgName("filename").hasArg() .withDescription("Location of the tuststore file").create(_TRUSTSTORE_LOCATION); Option truststorePassword = OptionBuilder.withLongOpt(TRUSTSTORE_PASSWORD).withArgName("password").hasArg() .withDescription("Password for the truststore file").create(_TRUSTSTORE_PASSWORD); Option keystoreLocation = OptionBuilder.withLongOpt(KEYSTORE_LOCATION).withArgName("filename").hasArg() .withDescription("Location of the keystore file").create(_KEYSTORE_LOCATION); Option keystorePassword = OptionBuilder.withLongOpt(KEYSTORE_PASSWORD).withArgName("password").hasArg() .withDescription("Password for the keystore file").create(_KEYSTORE_PASSWORD); Option passwordFileLocation = OptionBuilder.withLongOpt(PASSWORD_FILE_LOCATION).withArgName("filename") .hasArg().withDescription("Location of the password file").create(_PASSWORD_FILE_LOCATION); // --- Add options to the list --- // --- Help this.helpOptions.addOption(help); // --- Program command line options this.options.addOptionGroup(optionGroup); this.options.addOption(file); this.options.addOption(help); this.options.addOption(encryptedPassword); this.options.addOption(truststoreLocation); this.options.addOption(truststorePassword); this.options.addOption(keystoreLocation); this.options.addOption(keystorePassword); this.options.addOption(passwordFileLocation); this.options.addOption(targetApplication); }
From source file:fr.iphc.grid.jobmonitor.CeList.java
@SuppressWarnings("static-access") protected Options createOptions() { Options opt = new Options(); /*/*from w w w . j a v a 2 s . c o m*/ * opt.addOption(OptionBuilder.create()); OptionBuilder.withDescription( * "Display this help and exit"); * OptionBuilder.withLongOpt(LONGOPT_HELP); * opt.addOption(OptionBuilder.create(OPT_HELP)); * * * OptionBuilder.create(); OptionBuilder.withDescription( * "Output file directory"); OptionBuilder.hasArg(); * OptionBuilder.withArgName("OutDir"); * OptionBuilder.withLongOpt(LONGOPT_OUTDIR); * opt.addOption(OptionBuilder.create(OPT_OUTDIR)); * * OptionBuilder.create(); OptionBuilder.withDescription( * "Waiting TimeOut in minutes"); OptionBuilder.hasArg(); * OptionBuilder.withArgName("timeout"); * OptionBuilder.withLongOpt(LONGOPT_TIMEOUT); * opt.addOption(OptionBuilder.create(OPT_TIMEOUT)); * * * OptionGroup reqGroup = new OptionGroup(); OptionBuilder.create(); * OptionBuilder.withDescription("read job description from file <path>" * ); OptionBuilder.hasArg(); OptionBuilder.withArgName("path"); * OptionBuilder.withLongOpt(LONGOPT_FILE); * reqGroup.addOption(OptionBuilder.create(OPT_FILE)); * OptionBuilder.create(); OptionBuilder.withDescription( * "command to execute"); OptionBuilder.hasArg(); * reqGroup.addOption(OptionBuilder.create(JobDescription.EXECUTABLE)); * reqGroup.setRequired(false); opt.addOptionGroup(reqGroup); */ // command opt.addOption(OptionBuilder.withDescription("Display this help and exit").withLongOpt(LONGOPT_HELP) .create(OPT_HELP)); // required arguments opt.addOption(OptionBuilder.withDescription("the URL of the job service").hasArg().withArgName("URL") .withLongOpt(LONGOPT_RESOURCE).create(OPT_RESOURCE)); opt.addOption(OptionBuilder .withDescription("generate the job description in the targeted grid language " + "and exit (do not submit the job)") .withLongOpt(LONGOPT_DESCRIPTION).create(OPT_DESCRIPTION)); opt.addOption(OptionBuilder.withDescription("Output file directory").hasArg().withArgName("OutDir") .withLongOpt(LONGOPT_OUTDIR).create(OPT_OUTDIR)); opt.addOption(OptionBuilder.withDescription("Waiting TimeOut in minutes").hasArg().withArgName("timeout") .withLongOpt(LONGOPT_TIMEOUT).create(OPT_TIMEOUT)); opt.addOption(OptionBuilder.withDescription("File with CE/Path Format: CREAM://host:8443/path").hasArg() .withArgName("ce_path").withLongOpt(LONGOPT_CEPATH).create(OPT_CEPATH)); // optional group OptionGroup optGroup = new OptionGroup(); optGroup.addOption(OptionBuilder .withDescription( "print the job identifier as soon as it is submitted, " + "and wait for it to be finished") .withLongOpt(LONGOPT_JOBID).create(OPT_JOBID)); optGroup.addOption(OptionBuilder .withDescription("print the job identifier as soon as it is submitted, " + "and exit immediatly.") .withLongOpt(LONGOPT_BATCH).create(OPT_BATCH)); optGroup.setRequired(false); opt.addOptionGroup(optGroup); OptionGroup reqGroup = new OptionGroup(); reqGroup.addOption(OptionBuilder.withDescription("read job description from file <path>").hasArg() .withArgName("path").withLongOpt(LONGOPT_FILE).create(OPT_FILE)); reqGroup.addOption(o("command to execute").hasArg().create(JobDescription.EXECUTABLE)); // reqGroup.setRequired(true); opt.addOptionGroup(reqGroup); // job description opt.addOption(o("positional parameters for the command").hasArgs().create(JobDescription.ARGUMENTS)); opt.addOption(o("SPMD job type and startup mechanism").hasArg().create(JobDescription.SPMDVARIATION)); opt.addOption( o("total number of cpus requested for this job").hasArg().create(JobDescription.TOTALCPUCOUNT)); opt.addOption(o("number of process instances to start").hasArg().create(JobDescription.NUMBEROFPROCESSES)); opt.addOption(o("number of processes to start per host").hasArg().create(JobDescription.PROCESSESPERHOST)); opt.addOption( o("expected number of threads per process").hasArg().create(JobDescription.THREADSPERPROCESS)); opt.addOption(o("set of environment variables for the job").hasArgs().withValueSeparator() .create(JobDescription.ENVIRONMENT)); opt.addOption(o("working directory for the job").hasArg().create(JobDescription.WORKINGDIRECTORY)); opt.addOption(o("run the job in interactive mode").create(JobDescription.INTERACTIVE)); opt.addOption(o("pathname of the standard input file").hasArg().create(JobDescription.INPUT)); opt.addOption(o("pathname of the standard output file").hasArg().create(JobDescription.OUTPUT)); opt.addOption(o("pathname of the standard error file").hasArg().create(JobDescription.ERROR)); opt.addOption(o("a list of file transfer directives").hasArgs().create(JobDescription.FILETRANSFER)); opt.addOption(o("defines if output files get removed after the job finishes").hasArg() .create(JobDescription.CLEANUP)); opt.addOption(o("time at which a job should be scheduled").hasArg().create(JobDescription.JOBSTARTTIME)); opt.addOption(o("hard limit for the total job runtime").hasArg().create(JobDescription.WALLTIMELIMIT)); opt.addOption(o("estimated total number of CPU seconds which the job will require").hasArg() .create(JobDescription.TOTALCPUTIME)); opt.addOption(o("estimated amount of memory the job requires").hasArg() .create(JobDescription.TOTALPHYSICALMEMORY)); opt.addOption(o("compatible processor for job submission").hasArg().create(JobDescription.CPUARCHITECTURE)); opt.addOption(o("compatible operating system for job submission").hasArg() .create(JobDescription.OPERATINGSYSTEMTYPE)); opt.addOption( o("list of host names which are to be considered by the resource manager as candidate targets") .hasArgs().create(JobDescription.CANDIDATEHOSTS)); opt.addOption(o("name of a queue to place the job into").hasArg().create(JobDescription.QUEUE)); opt.addOption(o("name of an account or project name").hasArg().create(JobDescription.JOBPROJECT)); opt.addOption(o("set of endpoints describing where to report").hasArgs().create(JobDescription.JOBCONTACT)); // returns return opt; }
From source file:ditl.graphs.cli.Analyze.java
@Override protected void initOptions() { super.initOptions(); graph_options.setOptions(options);/* w ww. j a va 2s . c o m*/ final OptionGroup reportGroup = new OptionGroup(); reportGroup.addOption(new Option(null, nodeCountOption, false, "node count report")); reportGroup.addOption(new Option(null, transitTimesOption, false, "transit times report")); reportGroup.addOption(new Option(null, timeToFirstContactOption, false, "time to first contact report")); reportGroup.addOption(new Option(null, numContactsOption, false, "number of contacs distribution")); reportGroup.addOption(new Option(null, nodeDegreeOption, false, "node degree distribution over time")); reportGroup.addOption(new Option(null, contactsOption, false, "contact time distribution")); reportGroup.addOption(new Option(null, interContactsOption, false, "inter-contact time distribution")); reportGroup.addOption(new Option(null, anyContactsOption, false, "any-contact time distribution")); reportGroup .addOption(new Option(null, interAnyContactsOption, false, "inter-any-contact time distribution")); reportGroup.addOption( new Option(null, clusteringOption, false, "clustering coefficient distribution over time")); reportGroup.addOption(new Option(null, groupSizeOption, false, "distribution of group sizes over time")); reportGroup.addOption(new Option(null, reachabilityOption, false, "proportion of bi-directional and directional edges in the reachability graph")); reportGroup.setRequired(true); options.addOptionGroup(reportGroup); options.addOption(null, maxTimeOption, true, "Ignore event after <arg> seconds"); options.addOption(null, minTimeOption, true, "Ignore event before <arg> seconds"); }
From source file:net.sourceforge.squirrel_sql.plugins.dbcopy.cli.CommandLineArgumentProcessor.java
@SuppressWarnings("static-access") private void createOptions() { Option sourceOption = OptionBuilder.hasArg().isRequired().withLongOpt(SOURCE_SESSION) .withDescription("The name of the source alias to copy tables from").create(); options.addOption(sourceOption);// ww w . java 2s . com Option destOption = OptionBuilder.hasArg().isRequired().withLongOpt(DEST_SESSION) .withDescription("The name of the destination alias to copy tables to").create(); options.addOption(destOption); Option sourceSchemaOption = OptionBuilder.hasArg().withLongOpt(SOURCE_SCHEMA) .withDescription("The source schema to copy tables from").create(); Option sourceCatalogOption = OptionBuilder.hasArg().withLongOpt(SOURCE_CATALOG) .withDescription("The source catalog to copy tables from").create(); OptionGroup sourceSchemaGroup = new OptionGroup(); sourceSchemaGroup.setRequired(true); sourceSchemaGroup.addOption(sourceSchemaOption); sourceSchemaGroup.addOption(sourceCatalogOption); options.addOptionGroup(sourceSchemaGroup); Option listOption = OptionBuilder.hasArg().withLongOpt(TABLE_LIST) .withDescription("A comma-delimited list of tables to copy").create(); Option patternOption = OptionBuilder.hasArg().withLongOpt(TABLE_PATTERN) .withDescription("A regexp pattern to match source table names").create(); OptionGroup tableGroup = new OptionGroup(); tableGroup.setRequired(true); tableGroup.addOption(listOption); tableGroup.addOption(patternOption); options.addOptionGroup(tableGroup); Option destSchemaOption = OptionBuilder.hasArg().withLongOpt(DEST_SCHEMA) .withDescription("The destination schema to copy tables into").create(); Option destCatalogOption = OptionBuilder.hasArg().withLongOpt(DEST_CATALOG) .withDescription("The destination catalog to copy tables into").create(); OptionGroup destSchemaGroup = new OptionGroup(); destSchemaGroup.setRequired(true); destSchemaGroup.addOption(destSchemaOption); destSchemaGroup.addOption(destCatalogOption); options.addOptionGroup(destSchemaGroup); }
From source file:net.timbusproject.extractors.debiansoftwareextractor.CLI.java
private OptionGroup createOptionGroup(boolean required, Option... options) { OptionGroup group = new OptionGroup(); for (Option option : options) group.addOption(option);/*from w ww . j a va 2 s . c o m*/ group.setRequired(required); return group; }
From source file:org.apache.accumulo.core.util.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 ww w. jav a2s . c o m 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.DeleteScanIterCommand.java
@Override public Options getOptions() { final Options o = new Options(); OptionGroup nameGroup = new OptionGroup(); nameOpt = new Option("n", "name", true, "iterator to delete"); nameOpt.setArgName("itername"); allOpt = new Option("a", "all", false, "delete all scan iterators"); allOpt.setArgName("all"); nameGroup.addOption(nameOpt);//from ww w. j a v a 2 s. com nameGroup.addOption(allOpt); nameGroup.setRequired(true); o.addOptionGroup(nameGroup); o.addOption(OptUtil.tableOpt("table to delete scan iterators from")); return o; }