I am currently trying to make an cli app with Spring Shell.
I want the user to able to fast pick one of 2-3 options. My current code works fine in eclipse but when I start it in Powershell, i have to hit enter multiple times (at least 3 times) in order to select the option. After pressing enter once, nothing happens.
My current Method:
@ShellMethod(key = { "setService", "select" }, value = "Choose a Speech to Text Service")
public void setService() {
boolean success = false;
do {
this.console.write("Please select a speech recognition service. Type in the number and press enter:");
this.console.write("1. Google Speech API");
this.console.write("2. Bing Speech API");
// Get Input
Scanner s = new Scanner(System.in);
String input = s.nextLine();
// Select Service
switch (input) {
case "1":
/*
* do something...
*/
console.write("Google Speech API selected");
success = true;
break;
case "2":
/*
* do something...
*/
console.write("Bing Speech API selected");
success = true;
break;
default:
this.console.error("Input not valid. Please type a number and press Enter to select a Service");
break;
}
} while (!success);
}
How can i fix the issue with powershell or is there a more elegant way to perform this input?