- Command cmd = commands.get(name);
- if (cmd != null) {
- cmd.activate(this, args);
- } else {
- out("no command named '" + name + "'");
- }
- } catch (IOException e) {
- System.out.println("Error reading from command line");
- break;
- }
- }
+ void handleInput(String input) {
+ String[] splitInput = input.split("\\s+", 2);
+ String name = splitInput[0];
+ String[] args = splitInput.length == 2
+ ? splitInput[1].split("\\s+")
+ : new String[]{};
+
+ Command cmd = commands.get(name);
+ if (cmd != null) {
+ cmd.activate(this, args);
+ } else {
+ out("no command named '" + name + "'");
+ }