From be3f24968584e816ad89e318f1d0f9078f90d200 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Mon, 25 Nov 2019 22:59:11 +0100 Subject: [PATCH] Help command for listing all commands --- src/kaka/cakelight/Console.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/kaka/cakelight/Console.java b/src/kaka/cakelight/Console.java index 120d0f4..76bd6e5 100644 --- a/src/kaka/cakelight/Console.java +++ b/src/kaka/cakelight/Console.java @@ -25,7 +25,9 @@ public class Console extends Thread { this.cakelight = cakelight; this.config = config; reader = new BufferedReader(new InputStreamReader(System.in)); + register(new HelpCommand()); register(TwoColorNoiseMode.getCommand()); + } public CakeLight getCakelight() { return cakelight; @@ -35,6 +37,20 @@ public class Console extends Thread { return config; } + private class HelpCommand implements Command { + @Override + public String[] getNames() { + return new String[] {"?", "h", "help"}; + } + + @Override + public void activate(Console console, String[] args) { + for (Command c : commandList) { + System.out.println(String.join("|", c.getNames())); + } + } + } + private void register(Command cmd) { for (String name : cmd.getNames()){ if (commands.containsKey(name)) { -- 2.11.0