use of com.gianlu.consoleui.Choice.ChoiceAnswer in project PretendYoureXyzzyReborn by devgianlu.
the class ConsoleClient method mainMenu.
private void mainMenu() throws IOException {
ListChoicePrompt.Builder builder = new ListChoicePrompt.Builder();
builder.text("Request operation:").name("req");
for (Operations op : Operations.values()) builder.newItem().name(op.toString()).text(op.name()).add();
ChoiceAnswer answer = prompt.prompt(builder.build());
Operations op = Operations.parse(answer.getName());
JsonObject req = client.createRequest(op);
Pair<String, String> additionalParams;
do {
additionalParams = askForRequestParam();
if (additionalParams != null)
req.addProperty(additionalParams.getKey(), additionalParams.getValue());
} while (additionalParams != null);
System.out.println("REQUEST: " + req);
JsonObject resp;
try {
resp = client.sendMessageBlocking(req);
} catch (InterruptedException | PyxException ex) {
Logger.severe(ex);
mainMenu();
return;
}
System.out.println("RESPONSE: " + resp);
mainMenu();
}
Aggregations