Java Code Examples for picocli.CommandLine.Model.ArgSpec#splitValue()

The following examples show how to use picocli.CommandLine.Model.ArgSpec#splitValue() . 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: ArgSplitTest.java    From picocli with Apache License 2.0 5 votes vote down vote up
@Test
public void testArgSpecSplitValue_SplitsQuotedValuesIfConfigured() {
    ParserSpec parser = new ParserSpec().splitQuotedStrings(true);
    ArgSpec spec = PositionalParamSpec.builder().type(String[].class).splitRegex(",").build();
    String[] actual = spec.splitValue("a,b,\"c,d,e\",f", parser, Range.valueOf("0"), 0);
    assertArrayEquals(new String[]{"a", "b", "\"c", "d" , "e\"", "f"}, actual);
}
 
Example 2
Source File: ArgSplitTest.java    From picocli with Apache License 2.0 5 votes vote down vote up
@Test
public void testArgSpecSplitValue_RespectsQuotedValuesByDefault() {
    ParserSpec parser = new ParserSpec();
    ArgSpec spec = PositionalParamSpec.builder().type(String[].class).splitRegex(",").build();
    String[] actual = spec.splitValue("a,b,\"c,d,e\",f", parser, Range.valueOf("0"), 0);
    assertArrayEquals(new String[]{"a", "b", "\"c,d,e\"", "f"}, actual);
}
 
Example 3
Source File: ArgSplitTest.java    From picocli with Apache License 2.0 5 votes vote down vote up
@Test
public void testArgSpecSplitValue_MultipleQuotedValues() {
    ParserSpec parser = new ParserSpec();
    ArgSpec spec = PositionalParamSpec.builder().type(String[].class).splitRegex(",").build();
    String[] actual = spec.splitValue("a,b,\"c,d,e\",f,\"xxx,yyy\"", parser, Range.valueOf("0"), 0);
    assertArrayEquals(new String[]{"a", "b", "\"c,d,e\"", "f", "\"xxx,yyy\""}, actual);
}
 
Example 4
Source File: ArgSplitTest.java    From picocli with Apache License 2.0 5 votes vote down vote up
@Test
public void testArgSpecSplitValue_MultipleQuotedValues_QuotesTrimmedIfRequested() {
    ParserSpec parser = new ParserSpec().trimQuotes(true);
    ArgSpec spec = PositionalParamSpec.builder().type(String[].class).splitRegex(",").build();
    String[] actual = spec.splitValue("a,b,\"c,d,e\",f,\"xxx,yyy\"", parser, Range.valueOf("0"), 0);
    assertArrayEquals(new String[]{"a", "b", "c,d,e", "f", "xxx,yyy"}, actual);
}