From: Tomas Wenström Date: Mon, 25 Nov 2019 21:59:11 +0000 (+0100) Subject: Help command for listing all commands X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=be3f24968584e816ad89e318f1d0f9078f90d200;p=kaka%2Fcakelight.git Help command for listing all commands --- 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)) {