Add uptime command
[xudocci.git] / src / main / java / net / pterodactylus / xdcc / ui / stdin / CommandReader.java
index e9bcc3c..66447b0 100644 (file)
@@ -63,7 +63,7 @@ public class CommandReader extends AbstractExecutionThreadService {
        private final BufferedReader reader;
 
        /** The writer to write the results to. */
-       private final Writer writer;
+       private final DuplicateLineSuppressingWriter writer;
        private final Collection<Download> failedDownloads;
 
        /**
@@ -93,6 +93,7 @@ public class CommandReader extends AbstractExecutionThreadService {
                commandBuilder.add(new FailedDownloadsCommand(failedDownloads));
                commandBuilder.add(new RestartCommand(core, failedDownloads));
                commandBuilder.add(new ResearchCommand(core));
+               commandBuilder.add(new UptimeCommand(core));
                commands = commandBuilder.build();
        }
 
@@ -110,6 +111,7 @@ public class CommandReader extends AbstractExecutionThreadService {
                        if (line.equals("")) {
                                line = lastLine;
                        }
+                       writer.reset();
                        String[] words = line.split(" +");
                        String commandName = words[0];
                        Collection<Command> eligibleCommands = findEligibleCommands(commandName);
@@ -121,6 +123,7 @@ public class CommandReader extends AbstractExecutionThreadService {
                                Command command = eligibleCommands.iterator().next();
                                List<String> parameters = from(asList(words)).skip(1).toList();
                                state = command.execute(state, parameters, writer);
+                               writer.flush();
                        }
 
                        lastLine = line;