package com.elgassia.bridge.view.tui;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Commands {
    Map<String, Command> commandMap = new HashMap<>();

    public Command parse(String[] cmd) {
        if (commandMap.containsKey(cmd[0])) {
            Command command = commandMap.get(cmd[0]);
            command.setArgs(cmd);
            return command;
        }
        return null;
    }

    public void add(String key, Command command) {
        commandMap.put(key, command);
    }

    public void remove(String key) {
        commandMap.remove(key);
    }

    public Set<String> keySet() {
        return commandMap.keySet();
    }

    public Command get(Object key) {
        return commandMap.get(key);
    }
}

@@ -751,11 +751,72 @@
 );%0A    %7D
+%0A%0A    public void clear() %7B%0A        commandMap.clear();%0A    %7D
 %0A%7D%0A

add Commands clear functionality