From fe55a0449c2f5d434357c481890d909fffd30b3a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Fri, 6 Dec 2019 23:26:55 +0100 Subject: [PATCH] Bugfix - let PipeController set modes The command design is still terrible --- src/kaka/cakelight/Commands.java | 2 +- src/kaka/cakelight/Console.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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 -- 2.11.0