Skip to content

Commit

Permalink
admin: Add completion for \c command
Browse files Browse the repository at this point in the history
Target: trunk
Require-notes: yes
Require-book: yes
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Patch: https://rb.dcache.org/r/7887/
  • Loading branch information
gbehrmann committed Mar 5, 2015
1 parent d0bff4a commit 662cece
Showing 1 changed file with 9 additions and 2 deletions.
@@ -1,5 +1,6 @@
package diskCacheV111.admin ;

import com.google.common.base.CharMatcher;
import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.Futures;
Expand Down Expand Up @@ -107,7 +108,7 @@ public class UserAdminShell
private static final String ADMIN_COMMAND_NOOP = "xyzzy";
private static final int CD_PROBE_MESSAGE_TIMEOUT_MS = 1000;
public static final StringsCompleter SHELL_COMMAND_COMPLETER =
new StringsCompleter("\\l", "\\s", "\\sn", "\\sp", "\\q", "\\h", "\\?");
new StringsCompleter("\\c", "\\l", "\\s", "\\sn", "\\sp", "\\q", "\\h", "\\?");

private final CellEndpoint _cellEndpoint;
private final CellStub _acmStub;
Expand Down Expand Up @@ -1391,14 +1392,20 @@ public int complete(String buffer, int cursor, List<CharSequence> candidates)
}

private int completeShell(String buffer, int cursor, List<CharSequence> candidates)
throws InterruptedException, CommandException, NoRouteToCellException
throws InterruptedException, CommandException, NoRouteToCellException, CacheException, ExecutionException
{
String[] command = buffer.split("\\s+", 2);
if (command.length == 1) {
return SHELL_COMMAND_COMPLETER.complete(buffer, cursor, candidates);
}

switch (command[0]) {
case "\\c":
if (CharMatcher.WHITESPACE.matchesAnyOf(command[1])) {
return -1;
}
candidates.addAll(expandCellPatterns(Collections.singletonList(command[1] + "*")));
return command[0].length() + 1;
case "\\sp":
return completeShell("PoolManager", command[0], command[1], cursor, candidates);
case "\\sn":
Expand Down

0 comments on commit 662cece

Please sign in to comment.