l = new ArgumentWithoutValue(this, "-l");
l.setExclusive(true);
final FilenameTabCompleter pathCompleter = Util.isWindows() ? WindowsFilenameTabCompleter.INSTANCE : DefaultFilenameTabCompleter.INSTANCE;
path = new ArgumentWithValue(this, pathCompleter, 0, "--path") {
@Override
public String getValue(ParsedCommandLine args) {
String value = super.getValue(args);
if(value != null) {
if(value.length() >= 0 && value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') {
value = value.substring(1, value.length() - 1);
}
value = pathCompleter.translatePath(value);
}
return value;
}
};
path.addCantAppearAfter(l);
force = new ArgumentWithoutValue(this, "--force", "-f");
force.addRequiredPreceding(path);
name = new ArgumentWithValue(this, new CommandLineCompleter() {
@Override
public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {
ParsedCommandLine args = ctx.getParsedCommandLine();
try {
if(path.isPresent(args)) {
return -1;
}
} catch (CommandFormatException e) {
return -1;
}
int nextCharIndex = 0;
while (nextCharIndex < buffer.length()) {
if (!Character.isWhitespace(buffer.charAt(nextCharIndex))) {
break;
}
++nextCharIndex;
}
if(ctx.getModelControllerClient() != null) {
List<String> deployments = Util.getDeployments(ctx.getModelControllerClient());
if(deployments.isEmpty()) {
return -1;
}
String opBuffer = buffer.substring(nextCharIndex).trim();
if (opBuffer.isEmpty()) {
candidates.addAll(deployments);
} else {
for(String name : deployments) {
if(name.startsWith(opBuffer)) {
candidates.add(name);
}
}
Collections.sort(candidates);
}
return nextCharIndex;
} else {
return -1;
}
}}, "--name");
name.addCantAppearAfter(l);
path.addCantAppearAfter(name);
//name.addRequiredPreceding(path);
rtName = new ArgumentWithValue(this, "--runtime-name");
rtName.addRequiredPreceding(path);
allServerGroups = new ArgumentWithoutValue(this, "--all-server-groups") {
@Override
public boolean canAppearNext(CommandContext ctx) throws CommandFormatException {
if(!ctx.isDomainMode()) {
return false;
}
return super.canAppearNext(ctx);
}
};
allServerGroups.addRequiredPreceding(path);
allServerGroups.addRequiredPreceding(name);
serverGroups = new ArgumentWithValue(this, new CommandLineCompleter() {
@Override
public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {
List<String> allGroups = Util.getServerGroups(ctx.getModelControllerClient());
if(buffer.isEmpty()) {
candidates.addAll(allGroups);