From: Tomas Wenström Date: Fri, 6 Dec 2019 22:26:55 +0000 (+0100) Subject: Bugfix - let PipeController set modes X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=fe55a0449c2f5d434357c481890d909fffd30b3a;p=kaka%2Fcakelight.git Bugfix - let PipeController set modes The command design is still terrible --- diff --git a/src/kaka/cakelight/Commands.java b/src/kaka/cakelight/Commands.java index 825ebe3..9a2be3b 100644 --- a/src/kaka/cakelight/Commands.java +++ b/src/kaka/cakelight/Commands.java @@ -59,7 +59,7 @@ class Commands { static Console.Command push() { return command(new String[] {"push"}, (console, args) -> { - Object obj = console.handleInput(String.join(" ", args)); + Object obj = console.internalHandleInput(String.join(" ", args)); if (obj instanceof Mode) { // obj could be anything, which should be fixed console.out("pushing mode " + obj.getClass().getSimpleName()); console.getCakelight().pushMode((Mode) obj); diff --git a/src/kaka/cakelight/Console.java b/src/kaka/cakelight/Console.java index 5dfe091..89acbbd 100644 --- a/src/kaka/cakelight/Console.java +++ b/src/kaka/cakelight/Console.java @@ -75,21 +75,21 @@ public class Console extends Thread { while (running) { System.out.print("> "); String input = reader.readLine(); - internalHandleInput(input); + handleInput(input); } } catch (IOException e) { System.out.println("Error reading from command line"); } } - private void internalHandleInput(String input) { - Object obj = handleInput(input); + void handleInput(String input) { + Object obj = internalHandleInput(input); if (obj instanceof Mode) { cakelight.setMode((Mode) obj); } } - Object handleInput(String input) { + Object internalHandleInput(String input) { String[] splitInput = input.split("\\s+", 2); String name = splitInput[0]; String[] args = splitInput.length == 2