in azure-maven-plugin-lib/src/main/java/com/microsoft/azure/maven/prompt/DefaultPrompter.java [70:113]
public <T> List<T> promoteMultipleEntities(String header, String promotePrefix, String selectNoneMessage, List<T> entities,
Function<T, String> getNameFunc, boolean allowEmpty, String enterPromote, List<T> defaultValue) throws IOException {
final boolean hasDefaultValue = defaultValue != null && defaultValue.size() > 0;
final List<T> res = new ArrayList<>();
if (!allowEmpty && entities.size() == 1) {
return entities;
}
printOptionList(header, entities, null, getNameFunc);
final String example = TextUtils.blue("[1-2,4,6]");
final String hintMessage = String.format("(input numbers separated by comma, eg: %s, %s %s)", example, TextUtils.blue("ENTER"), enterPromote);
final String promoteMessage = String.format("%s%s: ", promotePrefix, hintMessage);
for (;;) {
System.out.print(promoteMessage);
System.out.flush();
final String input = reader.readLine();
if (StringUtils.isBlank(input)) {
if (hasDefaultValue) {
return defaultValue;
}
if (allowEmpty) {
return res;
}
System.out.println(selectNoneMessage);
}
if (isValidIntRangeInput(input)) {
try {
for (final int i : parseIntRanges(input, entities.size())) {
res.add(entities.get(i - 1));
}
if (res.size() > 0 || allowEmpty) {
return res;
}
System.out.print(selectNoneMessage);
} catch (NumberFormatException ex) {
System.out.println(TextUtils.yellow(String.format("The input value('%s') is invalid.", input)));
}
} else {
System.out.println(TextUtils.yellow(String.format("The input value('%s') is invalid.", input)));
}
System.out.flush();
}
}