Java Code Examples for org.jline.reader.impl.DefaultParser#ArgumentList

The following examples show how to use org.jline.reader.impl.DefaultParser#ArgumentList . 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: TestCLICompleter.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testCompletionWithFileArguments() {
    final String topCommand = NiFiRegistryCommandGroup.REGISTRY_COMMAND_GROUP;
    final String subCommand = "list-buckets";

    final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList(
            "", Arrays.asList(topCommand, subCommand, "-p", "src/test/resources/"), 3, -1, -1);

    final List<Candidate> candidates = new ArrayList<>();
    completer.complete(lineReader, parsedLine, candidates);
    assertTrue(candidates.size() > 0);

    boolean found = false;
    for (Candidate candidate : candidates) {
        if (candidate.value().equals("src/test/resources/test.properties")) {
            found = true;
            break;
        }
    }

    assertTrue(found);
}
 
Example 2
Source File: TestCLICompleter.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompletionWithWordIndexNegative() {
    final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList(
            "", Collections.emptyList(), -1, -1, -1);

    final List<Candidate> candidates = new ArrayList<>();
    completer.complete(lineReader, parsedLine, candidates);
    assertEquals(0, candidates.size());
}
 
Example 3
Source File: TestCLICompleter.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompletionWithWordIndexZero() {
    final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList(
            "", Collections.emptyList(), 0, -1, -1);

    final List<Candidate> candidates = new ArrayList<>();
    completer.complete(lineReader, parsedLine, candidates);
    assertEquals(completer.getTopLevelCommands().size(), candidates.size());
}
 
Example 4
Source File: TestCLICompleter.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompletionWithWordIndexOneAndMatching() {
    final String topCommand = NiFiRegistryCommandGroup.REGISTRY_COMMAND_GROUP;

    final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList(
            "", Collections.singletonList(topCommand), 1, -1, -1);

    final List<Candidate> candidates = new ArrayList<>();
    completer.complete(lineReader, parsedLine, candidates);
    assertEquals(completer.getSubCommands(topCommand).size(), candidates.size());
}
 
Example 5
Source File: TestCLICompleter.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompletionWithWordIndexOneAndNotMatching() {
    final String topCommand = "NOT-A-TOP-LEVEL-COMMAND";

    final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList(
            "", Collections.singletonList(topCommand), 1, -1, -1);

    final List<Candidate> candidates = new ArrayList<>();
    completer.complete(lineReader, parsedLine, candidates);
    assertEquals(0, candidates.size());
}
 
Example 6
Source File: TestCLICompleter.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompletionWithWordIndexTwoAndMatching() {
    final String topCommand = NiFiRegistryCommandGroup.REGISTRY_COMMAND_GROUP;
    final String subCommand = "list-buckets";

    final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList(
            "", Arrays.asList(topCommand, subCommand), 2, -1, -1);

    final List<Candidate> candidates = new ArrayList<>();
    completer.complete(lineReader, parsedLine, candidates);
    assertTrue(candidates.size() > 0);
    assertEquals(completer.getOptions(subCommand).size(), candidates.size());
}
 
Example 7
Source File: TestCLICompleter.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompletionWithWordIndexTwoAndNotMatching() {
    final String topCommand = NiFiRegistryCommandGroup.REGISTRY_COMMAND_GROUP;
    final String subCommand = "NOT-A-TOP-LEVEL-COMMAND";

    final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList(
            "", Arrays.asList(topCommand, subCommand), 2, -1, -1);

    final List<Candidate> candidates = new ArrayList<>();
    completer.complete(lineReader, parsedLine, candidates);
    assertEquals(0, candidates.size());
}
 
Example 8
Source File: TestCLICompleter.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompletionWithMultipleArguments() {
    final String topCommand = NiFiRegistryCommandGroup.REGISTRY_COMMAND_GROUP;
    final String subCommand = "list-buckets";

    final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList(
            "", Arrays.asList(topCommand, subCommand, "-ks", "foo", "-kst", "JKS"), 6, -1, -1);

    final List<Candidate> candidates = new ArrayList<>();
    completer.complete(lineReader, parsedLine, candidates);
    assertTrue(candidates.size() > 0);
    assertEquals(completer.getOptions(subCommand).size(), candidates.size());
}
 
Example 9
Source File: TestCLICompleter.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompletionForSessionVariableNames() {
    final String topCommand = "session";
    final String subCommand = "set";

    final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList(
            "", Arrays.asList(topCommand, subCommand), 2, -1, -1);

    final List<Candidate> candidates = new ArrayList<>();
    completer.complete(lineReader, parsedLine, candidates);
    assertTrue(candidates.size() > 0);
    assertEquals(SessionVariable.values().length, candidates.size());
}
 
Example 10
Source File: TestCLICompleter.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompletionForSessionVariableWithFiles() {
    final String topCommand = "session";
    final String subCommand = "set";

    final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList("",
            Arrays.asList(
                    topCommand,
                    subCommand,
                    SessionVariable.NIFI_CLIENT_PROPS.getVariableName(),
                    "src/test/resources/"),
            3, -1, -1);

    final List<Candidate> candidates = new ArrayList<>();
    completer.complete(lineReader, parsedLine, candidates);
    assertTrue(candidates.size() > 0);

    boolean found = false;
    for (Candidate candidate : candidates) {
        if (candidate.value().equals("src/test/resources/test.properties")) {
            found = true;
            break;
        }
    }

    assertTrue(found);
}