Moved out increments

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
Emmanuel Bigeon 2018-10-14 09:28:04 -04:00
parent 74c66dcbdd
commit 50ac6eec06

View File

@ -137,17 +137,18 @@ public final class CLIPrompter {
* @param output the manager * @param output the manager
* @param choices the choices * @param choices the choices
* @param cancel the cancel option if it exists * @param cancel the cancel option if it exists
* @return the number of choices plus one (or the number of choices if there is * @return the index of last choice
* a cancel)
* @throws IOException if the manager was closed */ * @throws IOException if the manager was closed */
private static <U> Integer listChoices(final ConsoleOutput output, private static <U> Integer listChoices(final ConsoleOutput output,
final List<U> choices, final String cancel) throws IOException { final List<U> choices, final String cancel) throws IOException {
int index = 0; int index = 0;
for (final U u : choices) { for (final U u : choices) {
output.println(index++ + ") " + u); //$NON-NLS-1$ output.println(index + ") " + u); //$NON-NLS-1$
index++;
} }
if (cancel != null) { if (cancel != null) {
output.println(index++ + ") " + cancel); //$NON-NLS-1$ output.println(index + ") " + cancel); //$NON-NLS-1$
index++;
} }
return Integer.valueOf(index - 1); return Integer.valueOf(index - 1);
} }