List of usage examples for org.apache.commons.cli OptionBuilder hasArg
public static OptionBuilder hasArg()
From source file:edu.wustl.mir.erl.ihe.xdsi.util.StoreSCU.java
@SuppressWarnings("static-access") public static void addTmpFileOptions(Options opts) { opts.addOption(OptionBuilder.hasArg().withArgName("directory").withDescription(rb.getString("tmp-file-dir")) .withLongOpt("tmp-file-dir").create(null)); opts.addOption(OptionBuilder.hasArg().withArgName("prefix").withDescription(rb.getString("tmp-file-prefix")) .withLongOpt("tmp-file-prefix").create(null)); opts.addOption(OptionBuilder.hasArg().withArgName("suffix").withDescription(rb.getString("tmp-file-suffix")) .withLongOpt("tmp-file-suffix").create(null)); }
From source file:com.github.houbie.lesscss.LesscCommandLineParser.java
@SuppressWarnings("static-access") private static org.apache.commons.cli.Options createOptions() { org.apache.commons.cli.Options result = new org.apache.commons.cli.Options(); result.addOption("h", HELP_OPTION, false, "Print help (this message) and exit."); result.addOption(OptionBuilder.withLongOpt(INCLUDE_PATH_OPTION).hasArg() .withDescription("Set include paths. Separated by `:'. Use `;' on Windows.").create()); result.addOption("M", DEPENDS_OPTION, false, "Output a makefile import dependency list to stdout."); result.addOption(OptionBuilder.withLongOpt(NO_IE_COMPAT_OPTION) .withDescription("Disable IE compatibility checks.").create()); result.addOption(OptionBuilder.withLongOpt(NO_JS_OPTION).withDescription("Disable JavaScript in less files") .create());/*from w w w .ja v a 2s. c o m*/ result.addOption("l", LINT_OPTION, false, "Syntax check only (lint)."); result.addOption("s", SILENT_OPTION, false, "Suppress output of error messages."); result.addOption(OptionBuilder.withLongOpt(STRICT_IMPORTS_OPTION) .withDescription("Force evaluation of imports.").create()); result.addOption("v", VERSION_OPTION, false, "Print version number and exit."); result.addOption("x", COMPRESS_OPTION, false, "Compress output by removing some whitespaces."); result.addOption(OptionBuilder.withLongOpt(SOURCE_MAP_OPTION).hasOptionalArg() .withDescription( "--source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map)") .create()); result.addOption(OptionBuilder.withLongOpt(SOURCE_MAP__ROOTPATH_OPTION).hasArg() .withDescription("adds this path onto the sourcemap filename and less file paths").create()); result.addOption(OptionBuilder.withLongOpt(SOURCE_MAP__BASEPATH_OPTION).hasArg() .withDescription("Sets sourcemap base path, defaults to current working directory.").create()); result.addOption(OptionBuilder.withLongOpt(SOURCE_MAP_LESS_INLINE_OPTION) .withDescription("puts the less files into the map instead of referencing them").create()); result.addOption(OptionBuilder.withLongOpt(SOURCE_MAP_MAP_INLINE_OPTION) .withDescription("puts the map (and any less files) into the output css file").create()); result.addOption(OptionBuilder.withLongOpt(SOURCE_MAP_URL_OPTION).hasArg() .withDescription("the complete url and filename put in the less file").create()); result.addOption("rp", ROOT_PATH_OPTION, true, "Set rootpath for url rewriting in relative imports and urls. Works with or without the relative-urls option."); result.addOption("ru", RELATIVE_URLS_OPTION, false, "re-write relative urls to the base less file."); result.addOption("sm", STRICT_MATH_OPTION, false, "Turn on or off strict math, where in strict mode, math requires brackets. This option may default to on and then be removed in the future."); result.addOption("su", STRICT_UNITS_OPTION, false, "Allow mixed units, e.g. 1px+1em or 1px*1px which have units that cannot be represented."); result.addOption(OptionBuilder.withLongOpt(GLOBAL_VAR_OPTION).hasArg() .withDescription("--global-var='VAR=VALUE' Defines a variable that can be referenced by the file.") .create()); result.addOption(OptionBuilder.withLongOpt(MODIFY_VAR_OPTION).hasArg() .withDescription("--modify-var='VAR=VALUE' Modifies a variable already declared in the file.") .create()); result.addOption(OptionBuilder.withLongOpt(VERBOSE_OPTION).withDescription("Be verbose.").create()); result.addOption(OptionBuilder.withLongOpt(YUI_COMPRESS_OPTION) .withDescription("Compress output using YUI cssmin.").create()); //deprecated options result.addOption(OptionBuilder.hasArg().withLongOpt(OPTIMIZATION_LEVEL_OPTION).withType(Number.class) .withDescription( "[deprecated] -O0, -O1, -O2; Set the parser's optimization level. The lower the number, the less nodes it will create in the tree. This could matter for debugging, or if you want to access the individual nodes in the tree.") .create('O')); result.addOption(OptionBuilder.withLongOpt(LINE_NUMBERS_OPTION).hasArg().withDescription( "[deprecated] --line-numbers=TYPE Outputs filename and line numbers. TYPE can be either 'comments', which will output the debug info within comments, 'mediaquery' that will output the information within a fake media query which is compatible with the SASS format, and 'all' which will do both.") .create()); //additional lesscss options result.addOption("js", CUSTOM_JS_OPTION, true, "File with custom JavaScript functions."); result.addOption("e", ENCODING_OPTION, true, "Character encoding."); result.addOption( OptionBuilder.withLongOpt(CACHE_DIR_OPTION).hasArg().withDescription("Cache directory.").create()); result.addOption( OptionBuilder.withLongOpt(DAEMON_OPTION).withDescription("Start compiler daemon.").create()); result.addOption(OptionBuilder.hasArg().withLongOpt(ENGINE_OPTION) .withDescription( "JavaScript engine, either 'rhino' (default), 'nashorn' (requires JDK8) or 'commandline'.") .create()); return result; }
From source file:de.clusteval.data.dataset.generator.DataSetGenerator.java
/** * Adds the default options of dataset generators to the given Options * attribute/*from w w w .ja v a 2 s .c o m*/ * * @param options * The existing Options attribute, holding already the options of * the actual generator implementation. */ private void addDefaultOptions(final Options options) { OptionBuilder.withArgName("folderName"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The name of the folder to store this dataset in."); Option option = OptionBuilder.create("folderName"); options.addOption(option); OptionBuilder.withArgName("fileName"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The name of the dataset file to generate."); option = OptionBuilder.create("fileName"); options.addOption(option); OptionBuilder.withArgName("alias"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The alias of the data set."); option = OptionBuilder.create("alias"); options.addOption(option); }
From source file:com.hdfs.concat.crush.Crush.java
@SuppressWarnings("static-access") Options buildOptions() {/*w w w. j a v a 2s . com*/ Options options = new Options(); Option option; option = OptionBuilder.withDescription("Print this help message").withLongOpt("help").create("?"); options.addOption(option); option = OptionBuilder.hasArg().withArgName("directory regex").withDescription( "Regular expression that matches a directory name. Used to match a directory with a correponding replacement string") .withLongOpt("regex").create(); options.addOption(option); option = OptionBuilder.hasArg().withArgName("ignore file regex").withDescription( "Regular expression to apply for filtering out crush candidate files. Any files in the input crush directory matching this will be ignored") .withLongOpt("ignore-regex").create(); options.addOption(option); option = OptionBuilder.hasArg().withArgName("replacement string").withDescription( "Replacement string used with the corresponding regex to calculate the name of a directory's crush output file") .withLongOpt("replacement").create(); options.addOption(option); option = OptionBuilder.hasArg().withArgName("FQN input format") .withDescription( "Input format used to open the files of directories matching the corresponding regex") .withLongOpt("input-format").create(); options.addOption(option); option = OptionBuilder.hasArg().withArgName("FQN output format") .withDescription( "Output format used to open the files of directories matching the corresponding regex") .withLongOpt("output-format").create(); options.addOption(option); option = OptionBuilder.hasArg().withArgName("threshold").withDescription( "Threshold relative to the dfs block size over which a file becomes eligible for crushing. Must be in the range (0 and 1]. Default 0.75") .withLongOpt("threshold").create(); options.addOption(option); option = OptionBuilder.hasArg().withArgName("max-file-blocks").withDescription( "The maximum number of dfs blocks per output file. Input files are grouped into output files under the assumption that the input and output compression codecs have comparable efficiency. Default is 8.") .withLongOpt("max-file-blocks").create(); options.addOption(option); option = OptionBuilder.withDescription("Do not skip directories containing single files.") .withLongOpt("include-single-file-dirs").create(); options.addOption(option); option = OptionBuilder.hasArg().withArgName("compression codec") .withDescription("FQN of the compression codec to use or \"none\". Defaults to DefaultCodec.") .withLongOpt("compress").create(); options.addOption(option); option = OptionBuilder.withDescription("Operate in clone mode.").withLongOpt("clone").create(); options.addOption(option); option = OptionBuilder.withDescription("Info logging to console.").withLongOpt("info").create(); options.addOption(option); option = OptionBuilder.withDescription("Verbose logging to console.").withLongOpt("verbose").create(); options.addOption(option); return options; }
From source file:edu.wustl.mir.erl.ihe.xdsi.util.StoreSCU.java
@SuppressWarnings("static-access") private static void addRelatedSOPClassOptions(Options opts) { opts.addOption(null, "rel-ext-neg", false, rb.getString("rel-ext-neg")); opts.addOption(OptionBuilder.hasArg().withArgName("file|url") .withDescription(rb.getString("rel-sop-classes")).withLongOpt("rel-sop-classes").create(null)); }
From source file:com.sikulix.core.SX.java
static void checkArgs(String[] args) { boolean hasUserArgs = false; for (String arg : args) { if ("--".equals(arg)) { hasUserArgs = true;//www. j ava 2s. co m continue; } if (hasUserArgs) { trace("checkargs: user: %s", arg); userArgs.add(arg); } else { trace("checkargs: --sx: %s", arg); sxArgs.add(arg); } } if (sxArgs.size() > 0) { CommandLineParser parser = new PosixParser(); Options opts = new Options(); opts.addOption(OptionBuilder.hasOptionalArg().create('d')); opts.addOption(OptionBuilder.hasArg().create('o')); opts.addOption(OptionBuilder.hasArgs().create('r')); opts.addOption(OptionBuilder.hasArgs().create('t')); opts.addOption(OptionBuilder.hasArg(false).create('c')); opts.addOption(OptionBuilder.hasArg(false).create('q')); try { sxCommandArgs = parser.parse(opts, sxArgs.toArray(new String[0])); } catch (ParseException e) { terminate(1, "checkArgs: %s", e.getMessage()); } if (!isNull(sxCommandArgs)) { if (isArg("q")) { log.globalStop(); } else if (isArg("d")) { log.globalOn(log.DEBUG); } } } //TODO make options from SX args }
From source file:com.sshtools.appframework.ui.SshToolsApplication.java
/** * Add any required command line options to be passed to the Options object * supplied as an argument. Concrete Applications should overidde this, call * super.buildCLIOptions() then add any other options they might require. * /*from w ww .j av a 2s . c o m*/ * @param options * Options list to add option too */ public void buildCLIOptions(Options options) { OptionBuilder.withLongOpt("help"); OptionBuilder.withDescription("show this help"); Option help = OptionBuilder.create("?"); options.addOption(help); if (isReuseCapable()) { OptionBuilder.withLongOpt("nodaemon"); OptionBuilder.withDescription("do not start the instance re-use daemon"); Option noListen = OptionBuilder.create("d"); options.addOption(noListen); } OptionBuilder.withLongOpt("--reusePort"); OptionBuilder.withArgName("port"); OptionBuilder.hasArg(); OptionBuilder.withDescription("port on which to listen for re-use requests"); OptionBuilder.create("r"); options.addOption("e", "noOptionsAction", false, "dont allow the user to change options."); }
From source file:com.opengamma.bbg.loader.BloombergSecurityFileLoader.java
private static Option createSchemeOption() { OptionBuilder.withLongOpt(IDENTIFICATION_SCHEME); OptionBuilder.withDescription("Identification scheme"); OptionBuilder.hasArg(); OptionBuilder.withArgName("BLOOMBERG_TICKER, BLOOMBERG_BUID"); return OptionBuilder.create("s"); }
From source file:com.opengamma.bbg.loader.BloombergSecurityFileLoader.java
private static Option createOptionSize() { OptionBuilder.withLongOpt(OPTION);/*w w w. j a va 2 s . c om*/ OptionBuilder.withDescription("First x number of options to load"); OptionBuilder.hasArg(); OptionBuilder.withArgName("size"); return OptionBuilder.create("o"); }
From source file:goal.tools.Run.java
/** * Creates the command line options.//from www. j a v a 2s.c o m * * @return the command line options. */ private static Options createOptions() { Options options = new Options(); OptionBuilder.withDescription("Print all messages"); OptionBuilder.withLongOpt(OPTION_VERBOSE); options.addOption(OptionBuilder.create(OPTION_VERBOSE_SHORT)); OptionBuilder.withDescription("Print messages from parser"); options.addOption(OptionBuilder.create(OPTION_VERBOSE_PARSER)); OptionBuilder.withDescription("Print messages from info"); options.addOption(OptionBuilder.create(OPTION_VERBOSE_INFO)); OptionBuilder.withDescription("Print messages from error"); options.addOption(OptionBuilder.create(OPTION_VERBOSE_ERROR)); OptionBuilder.withDescription("Print messages from warning"); options.addOption(OptionBuilder.create(OPTION_VERBOSE_WARNING)); options.addOption(new Option(OPTION_HELP_SHORT, OPTION_HELP, false, "Displays this help")); OptionBuilder.withDescription("Shows the license"); OptionBuilder.withLongOpt(OPTION_LICENSE); options.addOption(OptionBuilder.create()); OptionBuilder.withLongOpt(OPTION_VERSION); OptionBuilder.withDescription("Shows the current version"); options.addOption(OptionBuilder.create()); OptionBuilder.withLongOpt(OPTION_REPEATS); OptionBuilder.withArgName("number"); OptionBuilder.withDescription("Number of times to repeat running all episodes"); OptionBuilder.hasArg(); OptionBuilder.withType(Number.class); options.addOption(OptionBuilder.create(OPTION_REPEATS_SHORT)); OptionBuilder.withLongOpt(OPTION_TIMEOUT); OptionBuilder.withArgName("number"); OptionBuilder.withDescription("Maximum time to run a system (in seconds)"); OptionBuilder.hasArg(); OptionBuilder.withType(Number.class); options.addOption(OptionBuilder.create(OPTION_TIMEOUT_SHORT)); OptionBuilder.withLongOpt(OPTION_RECURSIVE); OptionBuilder.withDescription("Recursively search for mas files"); options.addOption(OptionBuilder.create()); OptionBuilder.withLongOpt(OPTION_DEBUG); OptionBuilder.withDescription("Display out put from debugger while running agent"); options.addOption(OptionBuilder.create(OPTION_DEBUG_SHORT)); OptionBuilder.withLongOpt(OPTION_RMI_MESSAGING); OptionBuilder.hasArg(); OptionBuilder.withArgName("host"); OptionBuilder.withDescription( "Use RMI messaging middleware. Host is the location of the RMI server. Using \"localhost\" will initialize a RMI server"); options.addOption(OptionBuilder.create()); return options; }