List of usage examples for org.apache.commons.cli Option setRequired
public void setRequired(boolean required)
From source file:edu.wisc.my.portlets.dmp.tools.XmlMenuPublisherRunner.java
/** * Set up the command line options/*from ww w.jav a2s .c o m*/ */ private static Options setupOptions() { final Options opts = new Options(); final Option xmlSource = new Option(XML_FILE_OPT, true, "The relative or absolute file system location of the menu XML document."); xmlSource.setRequired(true); xmlSource.setArgs(1); xmlSource.setArgName("path"); xmlSource.setLongOpt("menuXmlFile"); opts.addOption(xmlSource); return opts; }
From source file:com.aliyun.openservices.odps.console.pub.StopInstanceCommand.java
static Options initOptions() { Options opts = new Options(); Option synchronizeFlag = new Option("sync", true, "synchronizeFlag"); synchronizeFlag.setRequired(false); opts.addOption(synchronizeFlag);//from ww w .ja v a 2s.com return opts; }
From source file:com.alibaba.rocketmq.namesrv.NamesrvStartup.java
public static Options buildCommandlineOptions(final Options options) { Option opt = new Option("c", "configFile", true, "Name server config properties file"); opt.setRequired(false); options.addOption(opt);// w ww .ja v a2 s .com opt = new Option("p", "printConfigItem", false, "Print all config item"); opt.setRequired(false); options.addOption(opt); return options; }
From source file:com.mebigfatguy.junitflood.JUnitFlood.java
private static Options createOptions() { Options options = new Options(); Option option; option = new Option("c", "classPath", true, "The classpath on which to generate unit tests"); option.setRequired(true); options.addOption(option);// ww w. j a v a2 s . c om option = new Option("a", "auxClassPath", true, "Auxilliary classpath needed to generate unit tests"); option.setRequired(true); options.addOption(option); options.addOption("o", "outputPath", true, "The output path where unit tests will be generated"); option.setRequired(true); options.addOption(option); options.addOption("r", "rulesFile", true, "The file that holds rules for generating classes"); options.addOption(option); return options; }
From source file:com.yahoo.athenz.example.ztoken.HttpExampleClient.java
private static CommandLine parseCommandLine(String[] args) { Options options = new Options(); Option domain = new Option("d", "domain", true, "domain name"); domain.setRequired(true); options.addOption(domain);/* ww w .j a v a 2s . c o m*/ Option service = new Option("s", "service", true, "service name"); service.setRequired(true); options.addOption(service); Option privateKey = new Option("p", "pkey", true, "private key path"); privateKey.setRequired(true); options.addOption(privateKey); Option keyId = new Option("k", "keyid", true, "key identifier"); keyId.setRequired(true); options.addOption(keyId); Option url = new Option("u", "url", true, "request url"); url.setRequired(true); options.addOption(url); Option ztsUrl = new Option("z", "ztsurl", true, "ZTS Server url"); ztsUrl.setRequired(true); options.addOption(ztsUrl); Option providerDomain = new Option("pd", "provider-domain", true, "Provider domain name"); providerDomain.setRequired(true); options.addOption(providerDomain); Option providerRole = new Option("pr", "provider-role", true, "Provider role name"); providerRole.setRequired(true); options.addOption(providerRole); CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.out.println(e.getMessage()); formatter.printHelp("http-example-client", options); System.exit(1); } return cmd; }
From source file:com.yahoo.athenz.example.instance.InstanceClientRefresh.java
private static CommandLine parseCommandLine(String[] args) { Options options = new Options(); Option domain = new Option("d", "domain", true, "domain name"); domain.setRequired(true); options.addOption(domain);/* w ww.j ava2 s .c o m*/ Option service = new Option("s", "service", true, "service name"); service.setRequired(true); options.addOption(service); Option provider = new Option("p", "provider", true, "provider name"); provider.setRequired(true); options.addOption(provider); Option instance = new Option("i", "instance", true, "instance id"); instance.setRequired(true); options.addOption(instance); Option dnsSuffix = new Option("dns", "dnssuffix", true, "provider dns suffix"); dnsSuffix.setRequired(true); options.addOption(dnsSuffix); Option instanceKey = new Option("ik", "instancekey", true, "instance private key path"); instanceKey.setRequired(true); options.addOption(instanceKey); Option ztsUrl = new Option("z", "ztsurl", true, "ZTS Server url"); ztsUrl.setRequired(true); options.addOption(ztsUrl); CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.out.println(e.getMessage()); formatter.printHelp("instance-client", options); System.exit(1); } return cmd; }
From source file:com.yahoo.athenz.example.zts.tls.client.ZTSAWSCredsClient.java
private static CommandLine parseCommandLine(String[] args) { Options options = new Options(); Option domain = new Option("d", "domain", true, "domain name"); domain.setRequired(true); options.addOption(domain);// www .j av a 2 s . c o m Option role = new Option("r", "role", true, "role name"); role.setRequired(true); options.addOption(role); Option key = new Option("k", "key", true, "private key path"); key.setRequired(true); options.addOption(key); Option cert = new Option("c", "cert", true, "certficate path"); cert.setRequired(true); options.addOption(cert); Option trustStore = new Option("t", "trustStorePath", true, "CA TrustStore path"); trustStore.setRequired(true); options.addOption(trustStore); Option trustStorePassword = new Option("p", "trustStorePassword", true, "CA TrustStore password"); trustStorePassword.setRequired(true); options.addOption(trustStorePassword); Option ztsUrl = new Option("z", "ztsurl", true, "ZTS Server url"); ztsUrl.setRequired(true); options.addOption(ztsUrl); CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.out.println(e.getMessage()); formatter.printHelp("zts-aws-creds-client", options); System.exit(1); } return cmd; }
From source file:com.octo.mbo.CopyNotes.java
static CommandLine parseCommandLine(String[] args) throws CommandLineException { Options options = new Options(); Option optSource = new Option("s", "Source file where the comments can be extracted (only pptx format supported)"); optSource.setRequired(true); optSource.setArgs(1);//from www .ja v a2 s.co m optSource.setLongOpt("source"); options.addOption(optSource); Option optTarget = new Option("t", "Target file where the comments are merged (case of pptx format)"); optTarget.setRequired(true); optTarget.setArgs(1); optTarget.setLongOpt("target"); options.addOption(optTarget); HelpFormatter formatter = new HelpFormatter(); final String header = "CopyNotes allows to extract, copy and merge notes of pptx files. \n" + "Notes can be merged with the notes of an existing files \n" + "Notes can be exported to a xml file with a custom format or imported \n" + "from this xml format and merged into an existing pptx document. \n" + "The target file is updated \n"; final String footer = ""; CommandLineParser cliParser = new DefaultParser(); try { return cliParser.parse(options, args); } catch (MissingOptionException mex) { log.error(mex.getMessage()); log.debug("Error parsing command line", mex); formatter.printHelp( "java -jar copypptxnotes-<version>-jar-with-dependencies.jar -s <source> -t <target>", header, options, footer); throw new CommandLineException("Missing option", mex); } catch (ParseException pex) { log.debug("Error parsing the command line. Please use CopyComment --help", pex); formatter.printHelp( "java -jar copypptxnotes-<version>-jar-with-dependencies.jar -s <source> -t <target>", header, options, footer); throw new CommandLineException("Parse Exception", pex); } }
From source file:hrytsenko.csv.Args.java
private static Option newOption(String name, String description, boolean required) { Option option = new Option(name, true, description); option.setArgs(UNLIMITED_VALUES);//from w w w .j a va 2s . c o m option.setRequired(required); return option; }
From source file:hrytsenko.gscripts.AppArgs.java
private static Option createOption(String name, String description, boolean required) { Option option = new Option(name, true, description); option.setArgs(Option.UNLIMITED_VALUES); option.setRequired(required); return option; }