try
{
writePrompt(formattedMessage);
} catch (IOException e)
{
throw new PrompterException("Failed to present prompt", e);
}
try
{
line = inputHandler.readLine();
} catch (IOException e)
{
throw new PrompterException("Failed to read user response", e);
}
if (StringUtils.isEmpty(line))
{
line = defaultReply;
}
if (line != null && !possibleValues.contains(line))
{
try
{
String invalid = "Invalid selection.";
if (useAnsiColor)
{
ANSIBuffer ansiBuffer = new ANSIBuffer();
ansiBuffer.append(ANSIBuffer.ANSICodes
.attrib(FG_RED))
.append(ANSIBuffer.ANSICodes
.attrib(BOLD))
.append("Invalid selection.")
.append(ANSIBuffer.ANSICodes
.attrib(OFF));
invalid = ansiBuffer.toString();
}
outputHandler.writeLine(invalid);
} catch (IOException e)
{
throw new PrompterException("Failed to present feedback", e);
}
}
}
while (line == null || !possibleValues.contains(line));