List of usage examples for org.apache.commons.cli Option setArgs
public void setArgs(int num)
From source file:org.azyva.dragom.tool.ReferenceGraphReportTool.java
/** * Initializes the class./*from w w w . j a va 2 s .c om*/ */ private synchronized static void init() { if (!ReferenceGraphReportTool.indInit) { Option option; CliUtil.initJavaUtilLogging(); ReferenceGraphReportTool.options = new Options(); option = new Option(null, null); option.setLongOpt("output-format"); option.setArgs(1); ReferenceGraphReportTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("graph"); ReferenceGraphReportTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("avoid-redundancy"); ReferenceGraphReportTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("module-versions"); ReferenceGraphReportTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("only-multiple-versions"); ReferenceGraphReportTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("only-matched-modules"); ReferenceGraphReportTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("most-recent-version-in-reference-graph"); ReferenceGraphReportTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("most-recent-static-version-in-scm"); ReferenceGraphReportTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("reference-paths"); ReferenceGraphReportTool.options.addOption(option); CliUtil.addStandardOptions(ReferenceGraphReportTool.options); CliUtil.addRootModuleVersionOptions(ReferenceGraphReportTool.options); ReferenceGraphReportTool.indInit = true; } }
From source file:org.azyva.dragom.tool.SetupJenkinsJobsTool.java
/** * Initializes the class./*from w w w . j ava2 s . c o m*/ */ private synchronized static void init() { if (!SetupJenkinsJobsTool.indInit) { Option option; CliUtil.initJavaUtilLogging(); SetupJenkinsJobsTool.options = new Options(); option = new Option(null, null); option.setLongOpt("items-created-file"); option.setArgs(1); SetupJenkinsJobsTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("items-created-file-mode"); option.setArgs(1); SetupJenkinsJobsTool.options.addOption(option); CliUtil.addStandardOptions(SetupJenkinsJobsTool.options); CliUtil.addRootModuleVersionOptions(SetupJenkinsJobsTool.options); SetupJenkinsJobsTool.indInit = true; } }
From source file:org.azyva.dragom.tool.SwitchToDynamicVersionTool.java
/** * Initializes the class./*from w w w . j ava2 s . co m*/ */ private synchronized static void init() { if (!SwitchToDynamicVersionTool.indInit) { Option option; SwitchToDynamicVersionTool.options = new Options(); option = new Option(null, null); option.setLongOpt("workspace-path"); option.setArgs(1); SwitchToDynamicVersionTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("root-module-version"); option.setArgs(1); SwitchToDynamicVersionTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("reference-graph-path-matcher"); option.setArgs(1); SwitchToDynamicVersionTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("no-confirm"); SwitchToDynamicVersionTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("help"); SwitchToDynamicVersionTool.options.addOption(option); SwitchToDynamicVersionTool.indInit = true; } }
From source file:org.azyva.dragom.tool.TaskInvokerTool.java
/** * Initializes the class.//from w ww . ja va 2 s . c o m */ private synchronized static void init() { if (!TaskInvokerTool.indInit) { Option option; TaskInvokerTool.options = new Options(); option = new Option(null, null); option.setLongOpt("workspace-path"); option.setArgs(1); TaskInvokerTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("root-module-version"); option.setArgs(1); TaskInvokerTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("reference-graph-path-matcher"); option.setArgs(1); TaskInvokerTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("help"); TaskInvokerTool.options.addOption(option); TaskInvokerTool.indInit = true; } }
From source file:org.azyva.dragom.tool.WorkspaceManagerTool.java
/** * Initializes the class./*from w ww .j av a2 s . c o m*/ */ private synchronized static void init() { if (!WorkspaceManagerTool.indInit) { Option option; CliUtil.initJavaUtilLogging(); WorkspaceManagerTool.options = new Options(); option = new Option(null, null); option.setLongOpt("commit-message"); option.setArgs(1); WorkspaceManagerTool.options.addOption(option); option = new Option(null, null); option.setLongOpt("ind-skip-check-unsync-local-changes"); WorkspaceManagerTool.options.addOption(option); CliUtil.addStandardOptions(WorkspaceManagerTool.options); WorkspaceManagerTool.indInit = true; } }
From source file:org.bonitasoft.platform.setup.PlatformSetupApplication.java
private Options createOptions() { Options options = new Options(); Option systemPropertyOption = new Option("D", "specify system property to override configuration from database.properties"); systemPropertyOption.setArgName("property=value"); systemPropertyOption.setValueSeparator('='); systemPropertyOption.setArgs(2); options.addOption(systemPropertyOption); options.addOption("f", "force", false, "Force push even if critical folders will be deleted"); return options; }
From source file:org.codeseed.common.config.ext.CommandLineOptionsBuilder.java
/** * Potentially adds an option to the supplied collection. Used by the * {@link #build()} method to populate an options collection. * * @param options/* www . ja v a 2s .c o m*/ * the current collection of options * @param groups * mappings of argument group identifiers to groups * @param method * the configuration method to look up */ protected void addOption(Options options, Map<String, OptionGroup> groups, Method method) { final CommandLine commandLine = method.getAnnotation(CommandLine.class); // Iterate over the triggers; take the first values String opt = null; String longOpt = null; for (String trigger : commandLine.value()) { if (!options.hasOption(trigger)) { if (opt == null && trigger.length() == 1) { opt = trigger; } else if (longOpt == null) { longOpt = trigger; } } } // Either we can use the method name or there is no option being added if (opt == null && longOpt == null) { String methodOpt = LOWER_CAMEL.to(LOWER_HYPHEN, method.getName()); if (!options.hasOption(methodOpt)) { longOpt = methodOpt; } else { // TODO Warn? return; } } // Create a new option Option option = new Option(opt, null); option.setLongOpt(longOpt); // Set the number of arguments based on the return type final Class<?> returnType = Primitives.wrap(method.getReturnType()); if (returnType.equals(Boolean.class)) { option.setArgs(0); } else if (Iterable.class.isAssignableFrom(returnType)) { option.setArgs(commandLine.maximum()); } else if (Map.class.isAssignableFrom(returnType)) { option.setArgs(2); option.setValueSeparator('='); } else { option.setArgs(1); } // Add some descriptive text if (bundle != null) { try { // TODO Does this make sense? String key = option.hasLongOpt() ? option.getLongOpt() : method.getName(); option.setDescription(bundle.getString(key + ".description")); } catch (MissingResourceException e) { option.setDescription(null); } } // Set argument names if (bundle != null && option.getArgs() > 0) { try { option.setArgName(bundle.getString(method.getName() + ".argName")); } catch (MissingResourceException e) { option.setArgName(null); } } // Add to either the collection or to the option groups String groupKey = commandLine.groupId(); if (groupKey.isEmpty()) { options.addOption(option); } else { OptionGroup group = groups.get(groupKey); if (group == null) { group = new OptionGroup(); groups.put(groupKey, group); } group.addOption(option); } }
From source file:org.deegree.coverage.tools.RasterOptionsParser.java
/** * Add the rasterio (loading) options to the given cli options. * //from ww w. j a va 2s .c o m * @param options */ public static void addRasterIOLineOptions(Options options) { Option option = new Option("rl", OPT_RASTER_LOCATION, true, "The location of (a) raster data file(s)"); option.setArgs(1); option.setArgName("dir|file"); option.setRequired(true); options.addOption(option); option = new Option("it", OPT_INPUT_TYPE, true, "Type of the input raster files, only if the location is a directory"); option.setArgs(1); option.setArgName(OPT_TYPE_DESC); // option.setRequired( true ); options.addOption(option); option = new Option("s_srs", OPT_CRS, true, "The srs of the input files."); option.setArgs(1); option.setArgName("epsg:code"); options.addOption(option); option = new Option("nd", OPT_NO_DATA, true, "Value to be used as no (missing) data (default 0)."); option.setArgs(1); options.addOption(option); option = new Option("ndt", OPT_NO_DATA_TYPE, true, "Type of no data value (defaults to byte)."); option.setArgs(1); option.setArgName("byte|short|..."); options.addOption(option); option = new Option("ol", OPT_ORIGIN, true, "Origin location of the raster files, eg. center (default) or outer."); option.setArgs(1); option.setArgName("center|outer"); options.addOption(option); option = new Option("r", OPT_RECURSIVE, false, "Search for raster files recursively in the given directory (default true)."); options.addOption(option); option = new Option("rcd", OPT_RASTER_CACHE_DIR, true, "Directory to be used for caching, (default: " + RasterCache.DEFAULT_CACHE_DIR.getAbsolutePath() + ")."); option.setArgs(1); option.setArgName("dir"); options.addOption(option); CommandUtils.addDefaultOptions(options); }
From source file:org.deegree.tools.coverage.converter.RasterConverter.java
private static Options initOptions() { Options options = new Options(); Option option = new Option(RasterOptionsParser.OPT_RASTER_OUT_LOC_ABBREV, OPT_RASTER_OUT_LOC, true, "the output directory for the raster tree, defaults to input dir"); option.setArgs(1); option.setArgName("dir|file"); options.addOption(option);/*from w w w .jav a 2 s . co m*/ option = new Option(OPT_OUTPUT_TYPE_ABBREV, OPT_OUTPUT_TYPE, true, "The output type of the rasters."); option.setArgs(1); option.setArgName(OPT_TYPE_DESC); option.setRequired(true); options.addOption(option); option = new Option(OPT_NUM_THREADS, "the number of threads used."); option.setArgs(1); option.setArgName("threads"); options.addOption(option); RasterOptionsParser.addRasterIOLineOptions(options); CommandUtils.addDefaultOptions(options); return options; }
From source file:org.deegree.tools.coverage.RTBClient.java
private static Options initOptions() { Options options = new Options(); Option option = new Option(OPT_T_SRS, "the srs of the target raster (defaults to the source srs)"); option.setArgs(1); option.setArgName("epsg code"); options.addOption(option);//w ww . j a v a 2s . c o m option = new Option(OPT_RASTER_OUT_LOC_ABBREV, OPT_RASTER_OUT_LOC, true, "the output directory for the raster tree"); option.setRequired(true); option.setArgs(1); option.setArgName("dir"); options.addOption(option); option = new Option(OPT_TILE_SIZE, "the max tile size in pixel (defaults to " + DEFAULT_TILE_SIZE + "). the actual tile size is calculated to reduce 'black' borders" + " (see force_size)"); option.setArgs(1); option.setArgName("size"); options.addOption(option); option = new Option(OPT_FORCE_SIZE, "use the given tile_size as it is, do not calculate the optimal tile size"); options.addOption(option); option = new Option(OPT_BBOX, "the target bbox"); option.setArgs(1); option.setArgName("x0,y0,x1,y1"); options.addOption(option); option = new Option(OPT_NUM_LEVELS, "the number of raster levels. when omitted, generate levels until a level contains one tile."); option.setArgs(1); option.setArgName("levels"); options.addOption(option); option = new Option(OPT_RES, "the target resolution for the first level in units/px."); option.setArgs(1); option.setLongOpt("base_resolution"); option.setArgName("units/px"); options.addOption(option); option = new Option(OPT_INTERPOLATION, "the raster interpolation (nn: nearest neighbour, bl: bilinear"); option.setArgs(1); option.setArgName("nn|bl"); options.addOption(option); option = new Option(OPT_OUTPUT_TYPE_ABBREV, OPT_OUTPUT_TYPE, true, "the output format (defaults to " + DEFAULT_OUTPUT_FORMAT + ")"); option.setArgs(1); option.setArgName(OPT_TYPE_DESC); options.addOption(option); option = new Option(OPT_NUM_THREADS, "the number of threads used."); option.setArgs(1); option.setArgName("threads"); options.addOption(option); CommandUtils.addDefaultOptions(options); RasterOptionsParser.addRasterIOLineOptions(options); return options; }