Help command for listing all commands
authorTomas Wenström <tomas.wenstrom@gmail.com>
Mon, 25 Nov 2019 21:59:11 +0000 (22:59 +0100)
committerTomas Wenström <tomas.wenstrom@gmail.com>
Mon, 25 Nov 2019 21:59:11 +0000 (22:59 +0100)
src/kaka/cakelight/Console.java

index 120d0f4..76bd6e5 100644 (file)
@@ -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)) {