Add “get” command to command reader.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Apr 2013 04:50:02 +0000 (06:50 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Apr 2013 04:50:02 +0000 (06:50 +0200)
src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java

index 059d63d..497c5fd 100644 (file)
@@ -29,6 +29,7 @@ import net.pterodactylus.xdcc.data.Bot;
 import net.pterodactylus.xdcc.data.Pack;
 
 import com.google.common.collect.Lists;
+import com.google.common.primitives.Ints;
 import com.google.common.util.concurrent.AbstractExecutionThreadService;
 
 /**
@@ -109,6 +110,11 @@ public class CommandReader extends AbstractExecutionThreadService {
                                        writer.write(String.format("[%d] %s (%s, %d%%%s)\n", counter++, dccReceiver.filename(), dccReceiver.size(), dccReceiver.progress() * 100 / dccReceiver.size(), dccReceiver.isRunning() ? "" : ", finished"));
                                }
                                writer.write("End of DCCs.\n");
+                       } else if (words[0].equalsIgnoreCase("get")) {
+                               Integer index = Ints.tryParse(words[1]);
+                               if ((index != null) && (index < lastResult.size())) {
+                                       core.fetch(lastResult.get(index).bot(), lastResult.get(index).pack());
+                               }
                        }
 
                        lastLine = line;