Search in sources :

Example 61 with DefaultParser

use of org.apache.commons.cli.DefaultParser in project athenz by yahoo.

the class HttpExampleClient method parseCommandLine.

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);
    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;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 62 with DefaultParser

use of org.apache.commons.cli.DefaultParser in project athenz by yahoo.

the class InstanceClientRefresh method parseCommandLine.

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);
    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;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 63 with DefaultParser

use of org.apache.commons.cli.DefaultParser in project athenz by yahoo.

the class HttpExampleClient method parseCommandLine.

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);
    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);
    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;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 64 with DefaultParser

use of org.apache.commons.cli.DefaultParser in project athenz by yahoo.

the class ZTSAWSCredsClient method parseCommandLine.

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);
    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;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 65 with DefaultParser

use of org.apache.commons.cli.DefaultParser in project athenz by yahoo.

the class HttpTLSClient method parseCommandLine.

private static CommandLine parseCommandLine(String[] args) {
    Options options = new Options();
    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("u", "url", true, "HTTP 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-tls-client", options);
        System.exit(1);
    }
    return cmd;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Aggregations

DefaultParser (org.apache.commons.cli.DefaultParser)65 CommandLine (org.apache.commons.cli.CommandLine)63 Options (org.apache.commons.cli.Options)49 CommandLineParser (org.apache.commons.cli.CommandLineParser)45 ParseException (org.apache.commons.cli.ParseException)43 HelpFormatter (org.apache.commons.cli.HelpFormatter)30 Option (org.apache.commons.cli.Option)20 IOException (java.io.IOException)8 ToolOptions (com.google.api.tools.framework.tools.ToolOptions)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 File (java.io.File)5 Config (com.twitter.heron.spi.common.Config)3 PrintStream (java.io.PrintStream)3 Topology (com.ibm.streamsx.topology.Topology)2 PackingException (com.twitter.heron.spi.packing.PackingException)2 FileNotFoundException (java.io.FileNotFoundException)2 PrintWriter (java.io.PrintWriter)2 Path (java.nio.file.Path)2 Properties (java.util.Properties)2