Search in sources :

Example 1 with TerminalString

use of org.aesh.readline.terminal.formatting.TerminalString in project wildfly-core by wildfly.

the class CliCompletionTestCase method complete.

// This completion is what aesh-readline completion is calling, so more
// similar to interactive CLI session
private List<String> complete(CommandContext ctx, String cmd, Boolean separator) {
    Completion<AeshCompleteOperation> completer = (Completion<AeshCompleteOperation>) ctx.getDefaultCommandCompleter();
    AeshCompleteOperation op = new AeshCompleteOperation(cmd, cmd.length());
    completer.complete(op);
    if (separator != null) {
        assertEquals(op.hasAppendSeparator(), separator);
    }
    List<String> candidates = new ArrayList<>();
    for (TerminalString ts : op.getCompletionCandidates()) {
        candidates.add(ts.getCharacters());
    }
    // aesh-readline does sort the candidates prior to display.
    Collections.sort(candidates);
    return candidates;
}
Also used : Completion(org.aesh.readline.completion.Completion) ArrayList(java.util.ArrayList) TerminalString(org.aesh.readline.terminal.formatting.TerminalString) TerminalString(org.aesh.readline.terminal.formatting.TerminalString) AeshCompleteOperation(org.aesh.complete.AeshCompleteOperation)

Example 2 with TerminalString

use of org.aesh.readline.terminal.formatting.TerminalString in project wildfly-core by wildfly.

the class CLICompletionHandler method complete.

@Override
public void complete(AeshCompleteOperation co) {
    LOG.debugf("Completing {0}", co.getBuffer());
    cliCompleter.complete(ctx, co, this);
    if (ctx.isColorOutput()) {
        List<TerminalString> completionCandidates = co.getCompletionCandidates();
        List<TerminalString> requiredCandidates = new ArrayList<>();
        for (TerminalString candidate : completionCandidates) {
            if (candidate.toString().endsWith("*") && !"*".equals(candidate.toString())) {
                TerminalString newCandidate = Util.formatRequired(candidate);
                requiredCandidates.add(newCandidate);
            }
        }
        completionCandidates.removeIf(new Predicate<TerminalString>() {

            @Override
            public boolean test(TerminalString candidate) {
                return candidate.toString().endsWith("*");
            }
        });
        completionCandidates.addAll(requiredCandidates);
    }
    LOG.debugf("Completion candidates {0}", co.getCompletionCandidates());
}
Also used : ArrayList(java.util.ArrayList) TerminalString(org.aesh.readline.terminal.formatting.TerminalString)

Example 3 with TerminalString

use of org.aesh.readline.terminal.formatting.TerminalString in project wildfly-core by wildfly.

the class CliCompletionTestCase method complete.

// This completion is what aesh-readline completion is calling, so more
// similar to interactive CLI session
private List<String> complete(CommandContext ctx, String cmd, Boolean separator, int offset) {
    Completion<AeshCompleteOperation> completer = (Completion<AeshCompleteOperation>) ctx.getDefaultCommandCompleter();
    AeshCompleteOperation op = new AeshCompleteOperation(cmd, cmd.length());
    completer.complete(op);
    if (separator != null) {
        assertEquals(op.hasAppendSeparator(), separator);
    }
    if (offset > 0) {
        assertEquals(op.getOffset(), offset);
    }
    List<String> candidates = new ArrayList<>();
    for (TerminalString ts : op.getCompletionCandidates()) {
        candidates.add(ts.getCharacters());
    }
    return candidates;
}
Also used : Completion(org.aesh.readline.completion.Completion) ArrayList(java.util.ArrayList) TerminalString(org.aesh.readline.terminal.formatting.TerminalString) TerminalString(org.aesh.readline.terminal.formatting.TerminalString) AeshCompleteOperation(org.aesh.complete.AeshCompleteOperation)

Example 4 with TerminalString

use of org.aesh.readline.terminal.formatting.TerminalString in project wildfly by wildfly.

the class SecurityCommandsTestCase method complete.

// This completion is what aesh-readline completion is calling, so more
// similar to interactive CLI session
private List<String> complete(CommandContext ctx, String cmd, Boolean separator) {
    Completion<AeshCompleteOperation> completer = (Completion<AeshCompleteOperation>) ctx.getDefaultCommandCompleter();
    AeshCompleteOperation op = new AeshCompleteOperation(cmd, cmd.length());
    completer.complete(op);
    if (separator != null) {
        assertEquals(op.hasAppendSeparator(), separator);
    }
    List<String> candidates = new ArrayList<>();
    for (TerminalString ts : op.getCompletionCandidates()) {
        candidates.add(ts.getCharacters());
    }
    // aesh-readline does sort the candidates prior to display.
    Collections.sort(candidates);
    return candidates;
}
Also used : Completion(org.aesh.readline.completion.Completion) ArrayList(java.util.ArrayList) TerminalString(org.aesh.readline.terminal.formatting.TerminalString) TerminalString(org.aesh.readline.terminal.formatting.TerminalString) AeshCompleteOperation(org.aesh.complete.AeshCompleteOperation)

Example 5 with TerminalString

use of org.aesh.readline.terminal.formatting.TerminalString in project wildfly by wildfly.

the class SecurityAuthCommandsTestCase method complete.

// This completion is what aesh-readline completion is calling, so more
// similar to interactive CLI session
private List<String> complete(CommandContext ctx, String cmd, Boolean separator) {
    Completion<AeshCompleteOperation> completer = (Completion<AeshCompleteOperation>) ctx.getDefaultCommandCompleter();
    AeshCompleteOperation op = new AeshCompleteOperation(cmd, cmd.length());
    completer.complete(op);
    if (separator != null) {
        assertEquals(op.hasAppendSeparator(), separator);
    }
    List<String> candidates = new ArrayList<>();
    for (TerminalString ts : op.getCompletionCandidates()) {
        candidates.add(ts.getCharacters());
    }
    // aesh-readline does sort the candidates prior to display.
    Collections.sort(candidates);
    return candidates;
}
Also used : Completion(org.aesh.readline.completion.Completion) ArrayList(java.util.ArrayList) TerminalString(org.aesh.readline.terminal.formatting.TerminalString) TerminalString(org.aesh.readline.terminal.formatting.TerminalString) AeshCompleteOperation(org.aesh.complete.AeshCompleteOperation)

Aggregations

TerminalString (org.aesh.readline.terminal.formatting.TerminalString)11 ArrayList (java.util.ArrayList)7 AeshCompleteOperation (org.aesh.complete.AeshCompleteOperation)6 Completion (org.aesh.readline.completion.Completion)4 List (java.util.List)2 CommandDefinition (org.aesh.command.CommandDefinition)2 CommandException (org.aesh.command.CommandException)2 CommandResult (org.aesh.command.CommandResult)2 Shell (org.aesh.command.shell.Shell)2 TerminalColor (org.aesh.readline.terminal.formatting.TerminalColor)2 ContextAwareCommandInvocation (org.infinispan.cli.impl.ContextAwareCommandInvocation)2 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)1 GenericKubernetesResource (io.fabric8.kubernetes.api.model.GenericKubernetesResource)1 Pod (io.fabric8.kubernetes.api.model.Pod)1 Secret (io.fabric8.kubernetes.api.model.Secret)1 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1 LocalPortForward (io.fabric8.kubernetes.client.LocalPortForward)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InetAddress (java.net.InetAddress)1