Java Code Examples for picocli.CommandLine.Model.OptionSpec#builder()

The following examples show how to use picocli.CommandLine.Model.OptionSpec#builder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractCommandSpecProcessor.java    From picocli with Apache License 2.0 5 votes vote down vote up
private void buildOption(Element element, Context context) {
    if (context.options.containsKey(element)) {
        return;
    }
    TypedMember typedMember = extractTypedMember(element, "@Option");
    if (typedMember != null) {
        OptionSpec.Builder builder = OptionSpec.builder(typedMember, context.factory);
        builder.completionCandidates(CompletionCandidatesMetaData.extract(element));
        builder.converters(TypeConverterMetaData.extract(element));
        builder.parameterConsumer(ParameterConsumerMetaData.extract(element));
        context.options.put(element, builder);
    }
}
 
Example 2
Source File: ModelOptionSpecTest.java    From picocli with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetterAndSetterOfUsageSplit() {
    OptionSpec.Builder builder = OptionSpec.builder("-x");
    builder.auxiliaryTypes(Integer.class, Integer.TYPE)
        .splitRegex("\\|")
        .splitRegexSynopsisLabel("|");
    assertEquals("\\|", builder.splitRegex());
    assertEquals("|", builder.splitRegexSynopsisLabel());
}
 
Example 3
Source File: ModelArgSpecTest.java    From picocli with Apache License 2.0 4 votes vote down vote up
@Test
public void testArgSpecBuilderObjectBindingToString() {
    Builder builder = OptionSpec.builder("-x");
    assertEquals("ObjectBinding(value=null)", builder.getter().toString());
}
 
Example 4
Source File: ModelOptionSpecTest.java    From picocli with Apache License 2.0 4 votes vote down vote up
@Test
public void testOptionSpecBuilder_negatableGetter() {
    OptionSpec.Builder builder = OptionSpec.builder("-x");
    assertFalse(builder.negatable());
}
 
Example 5
Source File: ModelOptionSpecTest.java    From picocli with Apache License 2.0 4 votes vote down vote up
@Test
public void testOptionSpec_fallbackValueGetter() {
    OptionSpec.Builder builder = OptionSpec.builder("-x");
    assertEquals("", builder.fallbackValue());
}