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

The following examples show how to use picocli.CommandLine.Model.PositionalParamSpec#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 testArgSpecSplitValueDebug() {
    PositionalParamSpec positional = PositionalParamSpec.builder().type(String[].class).splitRegex("b").build();

    System.setProperty("picocli.trace", "DEBUG");
    String[] values = positional.splitValue("abc", new CommandLine.Model.ParserSpec().splitQuotedStrings(true), CommandLine.Range.valueOf("1"), 1);
    System.clearProperty("picocli.trace");

    assertArrayEquals(new String[] {"a", "c"}, values);
}
 
Example 2
Source File: ArgSplitTest.java    From picocli with Apache License 2.0 5 votes vote down vote up
@Test
public void testArgSpecSplitWithEscapedBackslashInsideQuote() {
    PositionalParamSpec positional = PositionalParamSpec.builder().type(String[].class).splitRegex(";").build();

    System.setProperty("picocli.trace", "DEBUG");
    String value = "\"abc\\\\\\\";def\"";
    String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
    System.clearProperty("picocli.trace");

    assertArrayEquals(new String[] {"\"abc\\\\\\\";def\""}, values);
}
 
Example 3
Source File: ArgSplitTest.java    From picocli with Apache License 2.0 5 votes vote down vote up
@Test
public void testArgSpecSplitWithEscapedBackslashOutsideQuote() {
    PositionalParamSpec positional = PositionalParamSpec.builder().type(String[].class).splitRegex(";").build();

    System.setProperty("picocli.trace", "DEBUG");
    String value = "\\\\\"abc\\\";def\";\\\"a\\";
    String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
    System.clearProperty("picocli.trace");

    assertArrayEquals(new String[] {"\\\\\"abc\\\";def\"", "\\\"a\\"}, values);
}
 
Example 4
Source File: ArgSplitTest.java    From picocli with Apache License 2.0 5 votes vote down vote up
@Test
public void testArgSpecSplitBalancedQuotedValueDebug() {
    PositionalParamSpec positional = PositionalParamSpec.builder().type(String[].class).splitRegex(";").build();

    System.setProperty("picocli.trace", "DEBUG");
    String value = "\"abc\\\";def\"";
    String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
    System.clearProperty("picocli.trace");

    assertArrayEquals(new String[] {"\"abc\\\";def\""}, values);
}
 
Example 5
Source File: ArgSplitTest.java    From picocli with Apache License 2.0 5 votes vote down vote up
@Test
public void testArgSpecSplitUnbalancedQuotedValueDebug() {
    PositionalParamSpec positional = PositionalParamSpec.builder().type(String[].class).splitRegex(";").build();

    System.setProperty("picocli.trace", "DEBUG");
    String value = "\"abc\\\";def";
    String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
    System.clearProperty("picocli.trace");

    assertArrayEquals(new String[] {"\"abc\\\"", "def"}, values);
}