List of usage examples for org.apache.commons.cli Option setRequired
public void setRequired(boolean required)
From source file:com.avira.couchdoop.ArgsHelper.java
public static Option getOptionFromArg(Args.ArgDef arg) { Option option = new Option(arg.getShortName() + "", arg.getLongName(), arg.hasArg, arg.description); option.setRequired(arg.isRequired); return option; }
From source file:net.openhft.chronicle.queue.ChronicleReaderMain.java
public static void addOption(final Options options, final String opt, final String argName, final boolean hasArg, final String description, final boolean isRequired) { final Option option = new Option(opt, hasArg, description); option.setArgName(argName);/*w w w . ja va2 s . com*/ option.setRequired(isRequired); options.addOption(option); }
From source file:com.yahoo.athenz.example.zts.tls.client.ZTSTLSClientAccessToken.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);/*from ww w . j a va2 s .com*/ 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); Option idTokenService = new Option("s", "idTokenService", true, "ID Token Service Name"); idTokenService.setRequired(false); options.addOption(idTokenService); 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-tls-client", options); System.exit(1); } return cmd; }
From source file:com.mebigfatguy.roomstore.RoomStore.java
private static Options createOptions() { Options options = new Options(); Option option = new Option(NICK_NAME, true, "nickname to use to access irc channels"); option.setRequired(true); options.addOption(option);//from w w w . jav a2 s .co m option = new Option(IRCSERVER, true, "irc server url"); option.setRequired(true); options.addOption(option); option = new Option(CHANNELS, true, "space separated list of channels to connect to"); option.setRequired(true); option.setArgs(100); options.addOption(option); option = new Option(ENDPOINTS, true, "space separated list of cassandra server server/ports"); option.setOptionalArg(true); option.setRequired(false); option.setArgs(100); options.addOption(option); option = new Option(RF, true, "replication factor[default=1]"); option.setRequired(false); options.addOption(option); return options; }
From source file:com.yahoo.athenz.example.zms.tls.client.ZMSTLSClient.java
private static CommandLine parseCommandLine(String[] args) { Options options = new Options(); Option resource = new Option("r", "resource", true, "resource value"); resource.setRequired(true); options.addOption(resource);//from ww w . j a va2 s . c om Option action = new Option("a", "action", true, "action"); action.setRequired(true); options.addOption(action); Option principal = new Option("u", "principal", true, "principal to check for"); principal.setRequired(true); options.addOption(principal); 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 zmsUrl = new Option("z", "zmsurl", true, "ZMS Server url"); zmsUrl.setRequired(true); options.addOption(zmsUrl); 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("zms-tls-client", options); System.exit(1); } return cmd; }
From source file:com.yahoo.athenz.example.zts.tls.client.ZTSTLSClient.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 va2s . c o m Option service = new Option("s", "service", true, "service name"); service.setRequired(true); options.addOption(service); Option keyId = new Option("i", "keyid", true, "key id"); keyId.setRequired(true); options.addOption(keyId); 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); Option proxyUrl = new Option("x", "proxy", true, "Proxy Server url"); proxyUrl.setRequired(false); options.addOption(proxyUrl); 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-tls-client", options); System.exit(1); } return cmd; }
From source file:com.teradata.tempto.sql.SqlResultGenerator.java
private static Options configureCommandLineParser() { Options options = new Options(); Option propertiesOption = new Option("p", true, "Properties file"); propertiesOption.setRequired(true); Option sqlFileOption = new Option("s", true, "SQL file"); sqlFileOption.setRequired(true);/*from w w w. j a va 2 s . c o m*/ Option helpOption = new Option(HELP, "Print this message"); options.addOption(propertiesOption); options.addOption(sqlFileOption); options.addOption(helpOption); return options; }
From source file:info.bitoo.Daemon.java
private static Options createCommandLineOptions() { Option optConfig = new Option("c", "config", true, "configuration file location"); Option optPipe = new Option("p", "pipe", true, "unix pipe path"); optPipe.setRequired(true); Options cliOptions = new Options(); cliOptions.addOption(optConfig);/*ww w . j a v a 2 s .c om*/ cliOptions.addOption(optPipe); return cliOptions; }
From source file:jmxbf.java
/** * @param args//w w w . j av a 2 s .c o m * @return */ private static CommandLine getParsedCommandLine(String[] args) { Options options = new Options(); Option host = new Option("h", "host", true, "The JMX server IP address."); host.setRequired(true); options.addOption(host); Option port = new Option("p", "port", true, "The JMX server listening port."); port.setRequired(true); options.addOption(port); Option usernames = new Option("uf", "usernames-file", true, "File including the usernames, one per line."); usernames.setRequired(true); options.addOption(usernames); Option passwords = new Option("pf", "passwords-file", true, "File including the passwords, one per line."); passwords.setRequired(true); options.addOption(passwords); CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.out.println(e.getMessage()); formatter.printHelp("jmxbf", options); return null; //System.exit(1) } return cmd; }
From source file:com.google.play.developerapi.samples.ApplicationConfig.java
public static ApplicationConfig parseArgs(String[] args) { Options options = new Options(); try {/*w w w.j a v a 2 s .c om*/ CommandLineParser parser = new GnuParser(); Option appId = new Option("appId", "Application id (package name)"); appId.setArgs(1); appId.setRequired(true); options.addOption(appId); Option secrets = new Option("secrets", "Client secrets path"); secrets.setArgs(1); secrets.setRequired(true); options.addOption(secrets); Option account = new Option("account", "Service account email"); account.setArgs(1); account.setRequired(false); options.addOption(account); Option appName = new Option("appName", "Application name"); appName.setArgs(1); appName.setRequired(false); options.addOption(appName); Option apkFilePath = new Option("apkFilePath", "Apk file path"); apkFilePath.setArgs(1); apkFilePath.setRequired(false); options.addOption(apkFilePath); return new ApplicationConfig(parser.parse(options, args)); } catch (ParseException ex) { System.err.println(ex.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("android-publisher-api", options); return null; } }