Search in sources :

Example 51 with OptionParser

use of joptsimple.OptionParser in project jackrabbit-oak by apache.

the class OptionsTest method help.

@Test
public void help() throws Exception {
    OptionParser parser = new OptionParser();
    Options opts = new Options().withDisableSystemExit();
    opts.parseAndConfigure(parser, new String[] { "-h" });
    assertTrue(opts.getCommonOpts().isHelpRequested());
}
Also used : OptionParser(joptsimple.OptionParser) Test(org.junit.Test)

Example 52 with OptionParser

use of joptsimple.OptionParser in project jackrabbit-oak by apache.

the class OptionParserFactory method create.

public static OptionParser create() {
    OptionParser op = new OptionParser();
    addUsageOptions(op);
    addBlobOptions(op);
    addRdbOptions(op);
    addPathsOptions(op);
    addVersioningOptions(op);
    addMiscOptions(op);
    return op;
}
Also used : OptionParser(joptsimple.OptionParser)

Example 53 with OptionParser

use of joptsimple.OptionParser in project samza by apache.

the class YarnJobValidationTool method main.

public static void main(String[] args) throws Exception {
    CommandLine cmdline = new CommandLine();
    OptionParser parser = cmdline.parser();
    OptionSpec<String> validatorOpt = parser.accepts("metrics-validator", "The metrics validator class.").withOptionalArg().ofType(String.class).describedAs("com.foo.bar.ClassName");
    OptionSet options = cmdline.parser().parse(args);
    Config config = cmdline.loadConfig(options);
    MetricsValidator validator = null;
    if (options.has(validatorOpt)) {
        String validatorClass = options.valueOf(validatorOpt);
        validator = ClassLoaderHelper.<MetricsValidator>fromClassName(validatorClass);
    }
    YarnConfiguration hadoopConfig = new YarnConfiguration();
    hadoopConfig.set("fs.http.impl", HttpFileSystem.class.getName());
    hadoopConfig.set("fs.https.impl", HttpFileSystem.class.getName());
    ClientHelper clientHelper = new ClientHelper(hadoopConfig);
    new YarnJobValidationTool(new JobConfig(config), clientHelper.yarnClient(), validator).run();
}
Also used : CommandLine(org.apache.samza.util.CommandLine) ClientHelper(org.apache.samza.job.yarn.ClientHelper) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) JobConfig(org.apache.samza.config.JobConfig) Config(org.apache.samza.config.Config) HttpFileSystem(org.apache.samza.util.hadoop.HttpFileSystem) OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser) JobConfig(org.apache.samza.config.JobConfig) MetricsValidator(org.apache.samza.metrics.MetricsValidator)

Example 54 with OptionParser

use of joptsimple.OptionParser in project spring-boot by spring-projects.

the class OptionHandler method getParser.

public OptionParser getParser() {
    if (this.parser == null) {
        this.parser = new OptionParser();
        options();
    }
    return this.parser;
}
Also used : OptionParser(joptsimple.OptionParser)

Example 55 with OptionParser

use of joptsimple.OptionParser in project spring-framework by spring-projects.

the class JOptCommandLinePropertySourceTests method withCustomNonOptionArgsNameAndNoNonOptionArgsPresent.

@Test
public void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() {
    OptionParser parser = new OptionParser();
    parser.accepts("o1").withRequiredArg();
    parser.accepts("o2");
    OptionSet optionSet = parser.parse("--o1=v1", "noa1", "--o2", "noa2");
    CommandLinePropertySource<?> ps = new JOptCommandLinePropertySource(optionSet);
    ps.setNonOptionArgsPropertyName("NOA");
    assertThat(ps.containsProperty("nonOptionArgs"), is(false));
    assertThat(ps.containsProperty("NOA"), is(true));
    assertThat(ps.containsProperty("o1"), is(true));
    assertThat(ps.containsProperty("o2"), is(true));
    String nonOptionArgs = ps.getProperty("NOA");
    assertThat(nonOptionArgs, equalTo("noa1,noa2"));
}
Also used : OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser) Test(org.junit.Test)

Aggregations

OptionParser (joptsimple.OptionParser)121 OptionSet (joptsimple.OptionSet)94 File (java.io.File)35 OptionException (joptsimple.OptionException)16 IOException (java.io.IOException)15 List (java.util.List)13 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 Cluster (voldemort.cluster.Cluster)8 FileNotFoundException (java.io.FileNotFoundException)6 StoreDefinition (voldemort.store.StoreDefinition)6 Closer (com.google.common.io.Closer)5 BufferedReader (java.io.BufferedReader)5 Properties (java.util.Properties)5 OptionSpec (joptsimple.OptionSpec)5 Node (voldemort.cluster.Node)5 ByteArray (voldemort.utils.ByteArray)5 ClusterMapper (voldemort.xml.ClusterMapper)5 MongoClientURI (com.mongodb.MongoClientURI)4 FileReader (java.io.FileReader)4