List of usage examples for org.apache.commons.cli OptionBuilder withDescription
public static OptionBuilder withDescription(String newDescription)
From source file:org.schreibubi.JCombinationsTools.settings.SettingsSingleton.java
@SuppressWarnings("static-access") private SettingsSingleton(String programName, SettingsInterface[] settingsEnum) { this.programName = programName; this.settingsEnum = settingsEnum; propArray[0] = new Properties(); propArray[1] = new Properties(propArray[0]); propArray[2] = new Properties(propArray[1]); // put default settings into lowest level... for (SettingsInterface a : settingsEnum) { propArray[0].setProperty(a.getLongArgName(), a.getDefaultValue()); }//from w w w . jav a 2 s. co m options = new Options(); // build up options for (SettingsInterface a : settingsEnum) { OptionBuilder o = OptionBuilder.withLongOpt(a.getLongArgName()); if (a.hasArgs()) { o = o.withDescription(a.getExplanation() + ", default \"" + a.getDefaultValue() + "\"").hasArg() .withArgName(a.getArgName()); } else { o = o.withDescription(a.getExplanation()); } options.addOption(o.create(a.getShortArgName())); } }
From source file:org.servalproject.maps.dataman.DataManCli.java
private static Options createOptions() { Options options = new Options(); // path to the input file OptionBuilder.withArgName("path"); OptionBuilder.hasArg(true);// w w w . j av a 2 s . c om OptionBuilder.withDescription("path to the input file"); OptionBuilder.isRequired(true); options.addOption(OptionBuilder.create("input")); // path to the output file OptionBuilder.withArgName("path"); OptionBuilder.hasArg(true); OptionBuilder.withDescription("path to the output file"); OptionBuilder.isRequired(true); options.addOption(OptionBuilder.create("output")); // task to undertake OptionBuilder.withArgName("text"); OptionBuilder.hasArg(true); OptionBuilder.withDescription("manipulation task to undertake"); OptionBuilder.isRequired(true); options.addOption(OptionBuilder.create("task")); // style information OptionBuilder.withArgName("text"); OptionBuilder.hasArg(true); OptionBuilder.withDescription("style definition information"); OptionBuilder.isRequired(false); options.addOption(OptionBuilder.create("style")); // verbose output or not options.addOption(new Option("verbose", "use verbose output")); return options; }
From source file:org.servalproject.maps.indexgenerator.MapIndexGenerator.java
private static Options createOptions() { Options options = new Options(); OptionBuilder.withArgName("path"); OptionBuilder.hasArg(true);/*from w ww . ja v a 2 s .co m*/ OptionBuilder.withDescription("path to the input directory"); OptionBuilder.isRequired(true); options.addOption(OptionBuilder.create("input")); OptionBuilder.withArgName("path"); OptionBuilder.hasArg(true); OptionBuilder.withDescription("path to the output file"); OptionBuilder.isRequired(true); options.addOption(OptionBuilder.create("output")); OptionBuilder.withArgName("text"); OptionBuilder.hasArg(true); OptionBuilder.withDescription("output format type"); OptionBuilder.isRequired(true); options.addOption(OptionBuilder.create("format")); return options; }
From source file:org.servalproject.maps.mapfiletester.MapFileTester.java
private static Options createOptions() { Options options = new Options(); OptionBuilder.withArgName("path"); OptionBuilder.hasArg(true);/*from w ww. jav a2s . c o m*/ OptionBuilder.withDescription("path to the input file / directory"); OptionBuilder.isRequired(true); options.addOption(OptionBuilder.create("input")); return options; }
From source file:org.servalproject.maps.osmbboxsplit.OsmBBoxSplit.java
private static Options createOptions() { Options options = new Options(); OptionBuilder.withArgName("path"); OptionBuilder.hasArg(true);//from w w w .j a v a 2 s.c o m OptionBuilder.withDescription("path to the input file / directory"); OptionBuilder.isRequired(true); options.addOption(OptionBuilder.create("input")); OptionBuilder.withArgName("int"); OptionBuilder.hasArg(true); OptionBuilder.withDescription("minimum size of file in MB to split (Default: " + MIN_FILE_SIZE + " MB)"); OptionBuilder.isRequired(false); options.addOption(OptionBuilder.create("minsize")); OptionBuilder.withArgName("path"); OptionBuilder.hasArg(true); OptionBuilder.withDescription("path to the ignore list file"); OptionBuilder.isRequired(false); options.addOption(OptionBuilder.create("ignore")); OptionBuilder.withArgName("path"); OptionBuilder.hasArg(true); OptionBuilder.withDescription("path to the output directory"); OptionBuilder.isRequired(false); options.addOption(OptionBuilder.create("output")); OptionBuilder.withArgName("path"); OptionBuilder.hasArg(true); OptionBuilder.withDescription("path to the osmosis script template"); OptionBuilder.isRequired(false); options.addOption(OptionBuilder.create("template")); return options; }
From source file:org.signserver.client.cli.defaultimpl.TimeStampCommand.java
public TimeStampCommand() { // Create options final Option help = new Option("help", false, "Print this message."); final Option b64 = new Option("base64", false, "Give this option if the stored request/reply should be " + "base64 encoded, default is not."); final Option verifyopt = new Option("verify", false, "Give this option if verification of a stored reply should " + "be done, work together with inrep and cafile. If given, no " + "request to the TSA will happen."); final Option printopt = new Option("print", false, "Prints content of a request, response and/or token"); OptionBuilder.hasArg();/*from w w w.j a v a 2s .co m*/ OptionBuilder.withDescription("Url of TSA, e.g. " + "http://127.0.0.1:8080/signserver/process?workerId=1."); OptionBuilder.withArgName("url"); final Option url = OptionBuilder.create("url"); OptionBuilder.hasArg(); OptionBuilder.withArgName("file"); OptionBuilder.withDescription( "Output file to store the recevied TSA " + "reply, if not given the reply is not stored."); final Option outrep = OptionBuilder.create("outrep"); OptionBuilder.hasArg(); OptionBuilder.withArgName("file"); OptionBuilder.withDescription("Input file containing an earlier stored " + "base64 encoded response, to verify." + "You must specify the verify flag also."); final Option inrep = OptionBuilder.create("inrep"); OptionBuilder.hasArg(); OptionBuilder.withArgName("file"); OptionBuilder.withDescription("Input file containing the PEM encoded " + "certificate of the TSA signer." + "Used to verify a stored response."); final Option cafileopt = OptionBuilder.create("signerfile"); OptionBuilder.hasArg(); OptionBuilder.withArgName("file"); OptionBuilder.withDescription( "Output file to store the sent TSA " + "request, if not given the request is not stored."); final Option outreq = OptionBuilder.create("outreq"); OptionBuilder.hasArg(); OptionBuilder.withArgName("file"); OptionBuilder.withDescription("File containing message to time stamp."); final Option infile = OptionBuilder.create("infile"); OptionBuilder.hasArg(); OptionBuilder.withArgName("string"); OptionBuilder.withDescription("String to be time stamped, if neither " + "instr or infile is given, the client works in test-mode " + "generating it's own message."); final Option instr = OptionBuilder.create("instr"); OptionBuilder.hasArg(); OptionBuilder.withArgName("file"); OptionBuilder.withDescription("Input file containing an earlier stored " + "request to use instead of creating a new. " + "You must specify the request flag also."); final Option inreq = OptionBuilder.create("inreq"); OptionBuilder.hasArg(); OptionBuilder.withArgName("num"); OptionBuilder.withDescription("Sleep a number of milliseconds after " + "each request. Default 1000 ms."); final Option optionSleep = OptionBuilder.create("sleep"); OptionBuilder.hasArg(false); OptionBuilder.withDescription("Request signer certificate"); final Option certReqOption = OptionBuilder.create("certreq"); OptionBuilder.hasArg(); OptionBuilder.withArgName("oid"); OptionBuilder.withDescription("Request timestamp issued under a policy OID"); final Option reqPolicyOption = OptionBuilder.create("reqpolicy"); // Add options options.addOption(help); options.addOption(verifyopt); options.addOption(printopt); options.addOption(url); options.addOption(outrep); options.addOption(inrep); options.addOption(cafileopt); options.addOption(outreq); options.addOption(b64); options.addOption(infile); options.addOption(instr); options.addOption(inreq); options.addOption(optionSleep); options.addOption(certReqOption); options.addOption(reqPolicyOption); for (Option option : KeyStoreOptions.getKeyStoreOptions()) { options.addOption(option); } }
From source file:org.signserver.client.cli.validationservice.ValidateCertificateCommand.java
public ValidateCertificateCommand() { Option help = new Option(OPTION_HELP, false, "Display this info"); Option silent = new Option(OPTION_SILENT, false, "Don't produce any output, only return value."); Option pem = new Option(OPTION_PEM, false, "Certificate is in PEM format (Default)."); Option der = new Option(OPTION_DER, false, "Certificate is in DER format."); OptionBuilder.withArgName("service-name"); OptionBuilder.hasArg();/*from w w w .j a v a 2 s . c o m*/ OptionBuilder.withDescription("The name or id of the validation service to process request. (Required)"); Option serviceOption = OptionBuilder.create(OPTION_SERVICE); OptionBuilder.withArgName("cert-file"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Path to certificate file (DER or PEM) (Required)."); Option certOption = OptionBuilder.create(OPTION_CERT); OptionBuilder.withArgName("hosts"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "A ',' separated string containing the hostnames of the validation service nodes. Ex 'host1.someorg.org,host2.someorg.org'. When using the HTTP protocol, only one host name can be specified. (Required)."); Option hostsOption = OptionBuilder.create(OPTION_HOSTS); OptionBuilder.withArgName("port"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Remote port of service (Default is 8080 or 8442 for SSL)."); Option portOption = OptionBuilder.create(OPTION_PORT); OptionBuilder.withArgName("certpurposes"); OptionBuilder.hasArg(); OptionBuilder.withDescription("A ',' separated string containing requested certificate purposes."); Option usagesOption = OptionBuilder.create(OPTION_CERTPURPOSES); OptionBuilder.withArgName("jks-file"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Path to JKS truststore containing trusted CA for SSL Server certificates."); Option truststore = OptionBuilder.create(OPTION_TRUSTSTORE); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Password to unlock the truststore."); Option truststorepwd = OptionBuilder.create(OPTION_TRUSTSTOREPWD); OptionBuilder.withArgName("servlet-url"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "URL to the webservice servlet. Default: " + SignServerWSClientFactory.DEFAULT_WSDL_URL + " when using the webservice protocol, otherwise /signserver/process"); Option servlet = OptionBuilder.create(OPTION_SERVLET); OptionBuilder.withArgName("protocol"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Protocol to use, either WEBSERVICES or HTTP. Default: WEBSERVICES."); Option protocol = OptionBuilder.create(OPTION_PROTOCOL); options.addOption(help); options.addOption(serviceOption); options.addOption(certOption); options.addOption(hostsOption); options.addOption(portOption); options.addOption(usagesOption); options.addOption(pem); options.addOption(der); options.addOption(silent); options.addOption(truststore); options.addOption(truststorepwd); options.addOption(servlet); options.addOption(protocol); }
From source file:org.skb.util.cli.CliApache.java
public void setPropOptions(TSPropertyMap prop) { String optType;//from w w w .j a v a 2s . c o m String optShort; String optLong; String optDescr; String optArgName; HashSet<String> ts = new HashSet<String>(prop.getRows()); for (Iterator<String> i = ts.iterator(); i.hasNext(); i.hasNext()) { String current = i.next(); if (prop.get(current, TSPropertyMap.pmValCliOptionType) != null) { optType = prop.get(current, TSPropertyMap.pmValCliOptionType).toString(); if (!(prop.get(current, TSPropertyMap.pmValCliOptionShort)).tsIsType(TEnum.TS_NULL)) optShort = prop.get(current, TSPropertyMap.pmValCliOptionShort).toString(); else optShort = null; if (!(prop.get(current, TSPropertyMap.pmValCliOptionLong)).tsIsType(TEnum.TS_NULL)) optLong = prop.get(current, TSPropertyMap.pmValCliOptionLong).toString(); else optLong = null; optDescr = prop.get(current, TSPropertyMap.pmValCliUsageDescr).toString(); optArgName = prop.get(current, TSPropertyMap.pmValCliUsageDescrAdd).toString(); if (optType.equals(TSRepository.TString.TS_ATOMIC_JAVA_STRING) || optType.equals(TSRepository.TString.TS_ATOMIC_JAVA_INTEGER) || optType.equals(TSRepository.TString.TS_ATOMIC_JAVA_DOUBLE) || optType.equals(TSRepository.TString.TS_ATOMIC_JAVA_LONG)) { if (optShort != null && optLong != null) { OptionBuilder.hasArg(); OptionBuilder.withDescription(optDescr); OptionBuilder.withLongOpt(optLong); OptionBuilder.withArgName(optArgName); this.options.addOption(OptionBuilder.create(optShort.charAt(0))); this.optionList.put(current, optLong); } else if (optLong != null) { OptionBuilder.hasArg(); OptionBuilder.withDescription(optDescr); OptionBuilder.withLongOpt(optLong); OptionBuilder.withArgName(optArgName); this.options.addOption(OptionBuilder.create()); this.optionList.put(current, optLong); } } else if (optType.equals(TSRepository.TString.TS_ATOMIC_JAVA_BOOLEAN)) { if (optShort != null && optLong != null) { OptionBuilder.withDescription(optDescr); OptionBuilder.withLongOpt(optLong); this.options.addOption(OptionBuilder.create(optShort.charAt(0))); this.optionList.put(current, optLong); } else if (optLong != null) { OptionBuilder.withDescription(optDescr); OptionBuilder.withLongOpt(optLong); this.options.addOption(OptionBuilder.create()); this.optionList.put(current, optLong); } } } } }
From source file:org.springframework.migrationanalyzer.commandline.OptionsFactory.java
@SuppressWarnings("static-access") Options create() {/* w w w . j a v a 2 s .c o m*/ Options options = new Options(); options.addOption(OptionBuilder // .withDescription("The type of the output to be created. Defaults to html.") // .hasArg() // .withArgName("outputType") // .create(OPTION_KEY_OUTPUT_TYPE)); options.addOption(OptionBuilder // .withDescription("The path of the output directory. Defaults to the current working directory") // .hasArg() // .withArgName("outputPath") // .create(OPTION_KEY_OUTPUT_PATH)); options.addOption(OptionBuilder // .withDescription( "Paths within the input to be excluded from the analysis. Supports Ant-style patterns and can be specified multiple times.") // .hasArg() // .withArgName("excludedPaths") // .withLongOpt("exclude") // .isRequired(false) // .create(OPTION_KEY_EXCLUDE)); return options; }
From source file:org.teavm.cli.TeaVMRunner.java
@SuppressWarnings("static-access") public static void main(String[] args) { Options options = new Options(); options.addOption(OptionBuilder.withArgName("target").hasArg() .withDescription("target type (javascript/js, webassembly/wasm)").create('t')); options.addOption(OptionBuilder.withArgName("directory").hasArg() .withDescription("a directory where to put generated files (current directory by default)") .withLongOpt("targetdir").create('d')); options.addOption(OptionBuilder.withArgName("file").hasArg() .withDescription("a file where to put decompiled classes (classes.js by default)") .withLongOpt("targetfile").create('f')); options.addOption(OptionBuilder.withDescription("causes TeaVM to generate minimized JavaScript file") .withLongOpt("minify").create("m")); options.addOption(OptionBuilder.withDescription("optimization level (1-3)").hasArg().withArgName("number") .create("O")); options.addOption(OptionBuilder.withArgName("separate|merge|none").hasArg() .withDescription("how to attach runtime. Possible values are: separate|merge|none") .withLongOpt("runtime").create("r")); options.addOption(OptionBuilder.withDescription("causes TeaVM to include default main page") .withLongOpt("mainpage").create()); options.addOption(/* w w w.j a va 2 s. c om*/ OptionBuilder.withDescription("Generate debug information").withLongOpt("debug").create('g')); options.addOption( OptionBuilder.withDescription("Generate source maps").withLongOpt("sourcemaps").create('G')); options.addOption( OptionBuilder.withDescription("Incremental build").withLongOpt("incremental").create('i')); options.addOption(OptionBuilder.withArgName("directory").hasArg() .withDescription("Incremental build cache directory").withLongOpt("cachedir").create('c')); options.addOption(OptionBuilder .withDescription("Wait for command after compilation, in order to enable hot recompilation") .withLongOpt("wait").create('w')); options.addOption(OptionBuilder.withArgName("classpath").hasArgs() .withDescription("Additional classpath that will be reloaded by TeaVM each time in wait mode") .withLongOpt("classpath").create('p')); options.addOption(OptionBuilder.withLongOpt("classalias").withArgName("alias").hasArgs() .withDescription("Alias names for classes. Specify as fully.qualified.Name:AliasName").create()); options.addOption(OptionBuilder.withLongOpt("wasm-version").withArgName("version").hasArg() .withDescription("WebAssembly binary version (11, 12, 13)").create()); if (args.length == 0) { printUsage(options); return; } CommandLineParser parser = new PosixParser(); CommandLine commandLine; try { commandLine = parser.parse(options, args); } catch (ParseException e) { printUsage(options); return; } TeaVMTool tool = new TeaVMTool(); if (commandLine.hasOption("t")) { switch (commandLine.getOptionValue('t').toLowerCase()) { case "javascript": case "js": tool.setTargetType(TeaVMTargetType.JAVASCRIPT); break; case "webassembly": case "wasm": tool.setTargetType(TeaVMTargetType.WEBASSEMBLY); break; } } if (commandLine.hasOption("d")) { tool.setTargetDirectory(new File(commandLine.getOptionValue("d"))); } if (commandLine.hasOption("f")) { tool.setTargetFileName(commandLine.getOptionValue("f")); } if (commandLine.hasOption("m")) { tool.setMinifying(true); } else { tool.setMinifying(false); } if (commandLine.hasOption("r")) { switch (commandLine.getOptionValue("r")) { case "separate": tool.setRuntime(RuntimeCopyOperation.SEPARATE); break; case "merge": tool.setRuntime(RuntimeCopyOperation.MERGED); break; case "none": tool.setRuntime(RuntimeCopyOperation.NONE); break; default: System.err.println("Wrong parameter for -r option specified"); printUsage(options); return; } } if (commandLine.hasOption("mainpage")) { tool.setMainPageIncluded(true); } if (commandLine.hasOption('g')) { tool.setDebugInformationGenerated(true); } if (commandLine.hasOption("O")) { int level; try { level = Integer.parseInt(commandLine.getOptionValue("O")); } catch (NumberFormatException e) { System.err.print("Wrong optimization level"); printUsage(options); return; } switch (level) { case 1: tool.setOptimizationLevel(TeaVMOptimizationLevel.SIMPLE); break; case 2: tool.setOptimizationLevel(TeaVMOptimizationLevel.ADVANCED); break; case 3: tool.setOptimizationLevel(TeaVMOptimizationLevel.FULL); break; default: System.err.print("Wrong optimization level"); printUsage(options); return; } } if (commandLine.hasOption('S')) { tool.setSourceMapsFileGenerated(true); } if (commandLine.hasOption('i')) { tool.setIncremental(true); } if (commandLine.hasOption('c')) { tool.setCacheDirectory(new File(commandLine.getOptionValue('c'))); } else { tool.setCacheDirectory(new File(tool.getTargetDirectory(), "teavm-cache")); } if (commandLine.hasOption('p')) { classPath = commandLine.getOptionValues('p'); } if (commandLine.hasOption("classalias")) { String[] aliasStrings = commandLine.getOptionValues("classalias"); for (String aliasString : aliasStrings) { int i = aliasString.indexOf(':'); if (i == -1) { System.err.print("Wrong alias specification"); printUsage(options); return; } ClassAlias alias = new ClassAlias(); alias.setClassName(aliasString.substring(0, i)); alias.setAlias(aliasString.substring(i + 1)); tool.getClassAliases().add(alias); } } boolean interactive = commandLine.hasOption('w'); setupWasm(tool, commandLine, options); args = commandLine.getArgs(); if (args.length > 1) { System.err.println("Unexpected arguments"); printUsage(options); return; } else if (args.length == 1) { tool.setMainClass(args[0]); } tool.setLog(new ConsoleTeaVMToolLog()); tool.getProperties().putAll(System.getProperties()); tool.setProgressListener(progressListener); if (interactive) { boolean quit = false; BufferedReader reader; try { reader = new BufferedReader(new InputStreamReader(System.in, "UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); System.exit(-2); return; } do { try { build(tool); } catch (Exception e) { e.printStackTrace(System.err); } System.out.println("Press enter to repeat or enter 'q' to quit"); try { String line = reader.readLine().trim(); if (!line.isEmpty()) { if (line.equals("q")) { quit = true; } else { System.out.println("Unrecognized command"); } } } catch (IOException e) { e.printStackTrace(); System.exit(-2); } } while (!quit); } else { try { build(tool); } catch (Exception e) { e.printStackTrace(System.err); System.exit(-2); } if (!tool.getProblemProvider().getSevereProblems().isEmpty()) { System.exit(-2); } } }