List of usage examples for org.apache.commons.cli OptionGroup OptionGroup
OptionGroup
From source file:de.zib.scalaris.Main.java
/** * Creates the options the command line should understand. * /* ww w. ja va 2 s . c o m*/ * @return the options the program understands */ private static Options getOptions() { Options options = new Options(); OptionGroup group = new OptionGroup(); /* Note: arguments are set to be optional since we implement argument * checks on our own (commons.cli is not flexible enough and only * checks for the existence of a first argument) */ options.addOption(new Option("h", "help", false, "print this message")); options.addOption(new Option("v", "verbose", false, "print verbose information, e.g. the properties read")); Option read = new Option("r", "read", true, "read an item"); read.setArgName("key"); read.setArgs(1); read.setOptionalArg(true); group.addOption(read); Option write = new Option("w", "write", true, "write an item"); write.setArgName("key> <value"); write.setArgs(2); write.setOptionalArg(true); group.addOption(write); Option publish = new Option("p", "publish", true, "publish a new message for the given topic"); publish.setArgName("topic> <message"); publish.setArgs(2); publish.setOptionalArg(true); group.addOption(publish); Option subscribe = new Option("s", "subscribe", true, "subscribe to a topic"); subscribe.setArgName("topic> <url"); subscribe.setArgs(2); subscribe.setOptionalArg(true); group.addOption(subscribe); Option unsubscribe = new Option("u", "unsubscribe", true, "unsubscribe from a topic"); unsubscribe.setArgName("topic> <url"); unsubscribe.setArgs(2); unsubscribe.setOptionalArg(true); group.addOption(unsubscribe); Option getSubscribers = new Option("g", "getsubscribers", true, "get subscribers of a topic"); getSubscribers.setArgName("topic"); getSubscribers.setArgs(1); getSubscribers.setOptionalArg(true); group.addOption(getSubscribers); Option delete = new Option("d", "delete", true, "delete an item (default timeout: 2000ms)\n" + "WARNING: This function can lead to inconsistent data (e.g. " + "deleted items can re-appear). Also when re-creating an item " + "the version before the delete can re-appear."); delete.setArgName("key> <[timeout]"); delete.setArgs(2); delete.setOptionalArg(true); group.addOption(delete); options.addOption(new Option("b", "minibench", false, "run mini benchmark")); options.addOption(new Option("lh", "localhost", false, "gets the local host's name as known to Java (for debugging purposes)")); options.addOptionGroup(group); return options; }
From source file:com.zimbra.cs.volume.VolumeCLI.java
@Override protected void setupCommandLineOptions() { super.setupCommandLineOptions(); Options options = getOptions();//from w ww .j a v a 2 s .co m 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:de.unibi.techfak.bibiserv.util.codegen.Main.java
/** * Returns "Choice" optiongroup for CodeGeneration. * * @return//from www . ja v a 2 s . co m */ private static OptionGroup getCMDLineOptionsGroups() { OptionGroup optionsgroup = new OptionGroup(); optionsgroup.setRequired(true); Option generate = new Option("g", "generate", true, "Generate app from xml description."); generate.setArgName("runnableitem.xml"); optionsgroup.addOption(new Option("V", "version", false, "version")) .addOption(new Option("h", "help", false, "help")).addOption(generate); return optionsgroup; }
From source file:com.cloudera.sqoop.tool.BaseSqoopTool.java
/** * @return RelatedOptions used by job management tools. *///from ww w . java 2 s .c om protected RelatedOptions getJobOptions() { RelatedOptions relatedOpts = new RelatedOptions("Job management arguments"); relatedOpts.addOption(OptionBuilder.withArgName("jdbc-uri").hasArg() .withDescription("Specify JDBC connect string for the metastore").withLongOpt(STORAGE_METASTORE_ARG) .create()); // Create an option-group surrounding the operations a user // can perform on jobs. OptionGroup group = new OptionGroup(); group.addOption(OptionBuilder.withArgName("job-id").hasArg().withDescription("Create a new saved job") .withLongOpt(JOB_CMD_CREATE_ARG).create()); group.addOption(OptionBuilder.withArgName("job-id").hasArg().withDescription("Delete a saved job") .withLongOpt(JOB_CMD_DELETE_ARG).create()); group.addOption(OptionBuilder.withArgName("job-id").hasArg() .withDescription("Show the parameters for a saved job").withLongOpt(JOB_CMD_SHOW_ARG).create()); Option execOption = OptionBuilder.withArgName("job-id").hasArg().withDescription("Run a saved job") .withLongOpt(JOB_CMD_EXEC_ARG).create(); group.addOption(execOption); group.addOption(OptionBuilder.withDescription("List saved jobs").withLongOpt(JOB_CMD_LIST_ARG).create()); relatedOpts.addOptionGroup(group); // Since the "common" options aren't used in the job tool, // add these settings here. relatedOpts.addOption(OptionBuilder.withDescription("Print more information while working") .withLongOpt(VERBOSE_ARG).create()); relatedOpts.addOption( OptionBuilder.withDescription("Print usage instructions").withLongOpt(HELP_ARG).create()); return relatedOpts; }
From source file:ape.Main.java
/** * This method generates all the options, and stores them in opts *///from w w w . j av a2 s . c o m public static void createOptions() { //System.out.println("creating options ..."); Options options = new Options(); options.addOption("h", "help", false, "Displays this help menu"); options.addOption("V", "version", false, "Displays the version number"); options.addOption(OptionBuilder.withValueSeparator().withDescription("Turn on verbose mode") .withLongOpt("verbose").create("v")); // Adds all of the commands in the service loader to an OptionGroup so that they are all mutually exclusive OptionGroup apeCommands = new OptionGroup(); Iterator<ApeCommand> iter = loader.iterator(); while (iter.hasNext()) { ApeCommand ac = iter.next(); apeCommands.addOption(ac.getOption()); //System.out.println(ac.getOption()); } options.addOptionGroup(apeCommands); // Makes the local and remote commands mutually exclusive OptionGroup remoteOrLocal = new OptionGroup(); remoteOrLocal.addOption(OptionBuilder.withArgName("HostnameList").hasArgs().withValueSeparator() .withDescription("Run commands remotely").withLongOpt("remote").create("R")); remoteOrLocal.addOption(OptionBuilder.withArgName("Command").withValueSeparator() .withDescription("Run commands locally").withLongOpt("local").create("L")); options.addOptionGroup(remoteOrLocal); opts = options; }
From source file:co.cask.cdap.cli.CLIMain.java
private static void addOptionalOption(Options options, Option option) { OptionGroup optionalGroup = new OptionGroup(); optionalGroup.setRequired(false);/*from w ww.ja v a 2s . com*/ optionalGroup.addOption(option); options.addOptionGroup(optionalGroup); }
From source file:at.favre.tools.dconvert.ui.CLIInterpreter.java
private static Options setupOptions(ResourceBundle bundle) { Options options = new Options(); Option srcOpt = Option.builder(SOURCE_ARG).required().argName("path to file or folder").hasArg(true) .desc(bundle.getString("arg.descr.cmd.src")).build(); Option srcScaleOpt = Option.builder(SCALE_ARG).argName("[float]|[int]dp").hasArg(true) .desc(bundle.getString("arg.descr.cmd.scale")).build(); Option dstOpt = Option.builder(DST_ARG).hasArg(true).argName("path") .desc(bundle.getString("arg.descr.cmd.dst")).build(); Option platform = Option.builder(PLATFORM_ARG).hasArg(true).argName("all|android|ios|win|web") .desc(MessageFormat.format(bundle.getString("arg.descr.cmd.platform"), Arguments.DEFAULT_PLATFORM)) .build();// w w w . jav a 2 s .c o m Option threadCount = Option.builder(THREADS_ARG).argName("1-8").hasArg(true).desc(MessageFormat .format(bundle.getString("arg.descr.cmd.threads"), String.valueOf(Arguments.DEFAULT_THREAD_COUNT))) .build(); Option roundingHandler = Option .builder(ROUNDING_MODE_ARG).argName("round|ceil|floor").hasArg(true).desc(MessageFormat .format(bundle.getString("arg.descr.cmd.rounding"), Arguments.DEFAULT_ROUNDING_STRATEGY)) .build(); Option compression = Option.builder(OUT_COMPRESSION_ARG).hasArg(true).argName("png|jpg|gif|bmp") .desc(bundle.getString("arg.descr.cmd.outcompression")).build(); Option compressionQuality = Option.builder(COMPRESSION_QUALITY_ARG).hasArg(true).argName("0.0-1.0") .desc(MessageFormat.format(bundle.getString("arg.descr.cmd.compression"), String.valueOf(Arguments.DEFAULT_COMPRESSION_QUALITY))) .build(); Option upScalingAlgo = Option.builder(UPSCALING_ALGO_ARG).hasArg(true) .argName(EScalingAlgorithm.getCliArgString(EScalingAlgorithm.Type.UPSCALING)) .desc(MessageFormat.format(bundle.getString("arg.descr.scalingalgo"), Arguments.DEFAULT_PLATFORM)) .build(); Option downScalingAlgo = Option.builder(DOWNSCALING_ALGO_ARG).hasArg(true) .argName(EScalingAlgorithm.getCliArgString(EScalingAlgorithm.Type.DOWNSCALING)) .desc(MessageFormat.format(bundle.getString("arg.descr.scalingalgo"), Arguments.DEFAULT_PLATFORM)) .build(); Option skipExistingFiles = Option.builder(SKIP_EXISTING_ARG) .desc(bundle.getString("arg.descr.skipexisting")).build(); Option androidIncludeLdpiTvdpi = Option.builder("androidIncludeLdpiTvdpi") .desc(bundle.getString("arg.descr.androidmipmap")).build(); Option mipmapInsteadOfDrawable = Option.builder("androidMipmapInsteadOfDrawable") .desc(bundle.getString("arg.descr.androidldpi")).build(); Option iosCreateImagesetFolders = Option.builder("iosCreateImagesetFolders") .desc(bundle.getString("arg.descr.iosimageset")).build(); Option skipUpscaling = Option.builder("skipUpscaling").desc(bundle.getString("arg.descr.skipupscaling")) .build(); Option verboseLog = Option.builder(VERBOSE_ARG).desc(bundle.getString("arg.descr.cmd.verbose")).build(); Option haltOnError = Option.builder("haltOnError").desc(bundle.getString("arg.descr.halterror")).build(); Option antiAliasing = Option.builder("antiAliasing").desc(bundle.getString("arg.descr.antialiasing")) .build(); Option enablePngCrush = Option.builder("postProcessorPngCrush").desc(bundle.getString("arg.descr.pngcrush")) .build(); Option postWebpConvert = Option.builder("postProcessorWebp").desc(bundle.getString("arg.descr.webp")) .build(); Option keepUnPostProcessed = Option.builder("keepOriginalPostProcessedFiles") .desc(bundle.getString("arg.descr.keeporiginal")).build(); Option dpScaleIsHeight = Option.builder(SCALE_IS_HEIGHT_DP_ARG) .desc(bundle.getString("arg.descr.cmd.dpIsHeight")).build(); Option dryRun = Option.builder("dryRun").desc(bundle.getString("arg.descr.dryrun")).build(); Option enableMozJpeg = Option.builder("postProcessorMozJpeg").desc(bundle.getString("arg.descr.mozjpeg")) .build(); Option cleanBeforeConvert = Option.builder("clean").desc(bundle.getString("arg.descr.clean")).build(); Option help = Option.builder("h").longOpt("help").desc(bundle.getString("arg.descr.cmd.help")).build(); Option version = Option.builder("v").longOpt("version").desc(bundle.getString("arg.descr.cmd.version")) .build(); Option gui = Option.builder("gui").desc(bundle.getString("arg.descr.cmd.gui")).build(); OptionGroup mainArgs = new OptionGroup(); mainArgs.addOption(srcOpt).addOption(help).addOption(version).addOption(gui); mainArgs.setRequired(true); options.addOption(srcScaleOpt).addOption(dstOpt); options.addOption(platform).addOption(compression).addOption(compressionQuality).addOption(threadCount) .addOption(roundingHandler).addOption(upScalingAlgo).addOption(downScalingAlgo); options.addOption(skipExistingFiles).addOption(skipUpscaling).addOption(androidIncludeLdpiTvdpi) .addOption(verboseLog).addOption(antiAliasing).addOption(dryRun).addOption(haltOnError) .addOption(mipmapInsteadOfDrawable).addOption(enablePngCrush).addOption(postWebpConvert) .addOption(dpScaleIsHeight).addOption(enableMozJpeg).addOption(keepUnPostProcessed) .addOption(iosCreateImagesetFolders).addOption(cleanBeforeConvert); options.addOptionGroup(mainArgs); return options; }
From source file:com.linkedin.helix.mock.storage.DummyProcess.java
@SuppressWarnings("static-access") synchronized private static Options constructCommandLineOptions() { Option helpOption = OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info") .create();// w w w. j a v a 2 s. c o m Option clusterOption = OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create(); clusterOption.setArgs(1); clusterOption.setRequired(true); clusterOption.setArgName("Cluster name (Required)"); Option hostOption = OptionBuilder.withLongOpt(hostAddress).withDescription("Provide host name").create(); hostOption.setArgs(1); hostOption.setRequired(true); hostOption.setArgName("Host name (Required)"); Option portOption = OptionBuilder.withLongOpt(hostPort).withDescription("Provide host port").create(); portOption.setArgs(1); portOption.setRequired(true); portOption.setArgName("Host port (Required)"); Option cmTypeOption = OptionBuilder.withLongOpt(helixManagerType) .withDescription("Provide cluster manager type (e.g. 'zk', 'static-file', or 'dynamic-file'") .create(); cmTypeOption.setArgs(1); cmTypeOption.setRequired(true); cmTypeOption.setArgName("Clsuter manager type (e.g. 'zk', 'static-file', or 'dynamic-file') (Required)"); // add an option group including either --zkSvr or --clusterViewFile Option fileOption = OptionBuilder.withLongOpt(clusterViewFile) .withDescription("Provide a cluster-view file for static-file based cluster manager").create(); fileOption.setArgs(1); fileOption.setRequired(true); fileOption.setArgName("Cluster-view file (Required for static-file based cluster manager)"); Option zkServerOption = OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address") .create(); zkServerOption.setArgs(1); zkServerOption.setRequired(true); zkServerOption.setArgName("ZookeeperServerAddress(Required for zk-based cluster manager)"); // Option rootNsOption = OptionBuilder.withLongOpt(rootNamespace) // .withDescription("Provide root namespace for dynamic-file based cluster manager").create(); // rootNsOption.setArgs(1); // rootNsOption.setRequired(true); // rootNsOption.setArgName("Root namespace (Required for dynamic-file based cluster manager)"); Option transDelayOption = OptionBuilder.withLongOpt(transDelay).withDescription("Provide state trans delay") .create(); transDelayOption.setArgs(1); transDelayOption.setRequired(false); transDelayOption.setArgName("Delay time in state transition, in MS"); OptionGroup optionGroup = new OptionGroup(); optionGroup.addOption(zkServerOption); optionGroup.addOption(fileOption); // optionGroup.addOption(rootNsOption); Options options = new Options(); options.addOption(helpOption); options.addOption(clusterOption); options.addOption(hostOption); options.addOption(portOption); options.addOption(transDelayOption); options.addOption(cmTypeOption); options.addOptionGroup(optionGroup); return options; }
From source file:com.opengamma.component.OpenGammaComponentServer.java
private static Options getOptions() { Options options = new Options(); options.addOption(new Option("h", HELP_OPTION, false, "print this help message")); options.addOptionGroup(new OptionGroup() .addOption(new Option("l", LOAD_ONLY_OPTION, false, "load the config, but do not start the server")) .addOption(new Option("p", PROPERTY_DISPLAY_OPTION, true, "displays the calculated value of a property"))); options.addOptionGroup(/*from ww w . ja va2 s.co m*/ new OptionGroup().addOption(new Option("q", QUIET_OPTION, false, "be quiet during startup")) .addOption(new Option("v", VERBOSE_OPTION, false, "be verbose during startup"))); return options; }
From source file:fr.iphc.grid.jobmanager.JobManager.java
@SuppressWarnings("static-access") protected Options createOptions() { Options opt = new Options(); // command/*from ww w . jav a 2s . c om*/ 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; }