✨ Add multiple downloads at the same time
[xudocci.git] / src / main / java / net / pterodactylus / xdcc / ui / stdin / DownloadCommand.kt
index 7915472..8636e06 100644 (file)
@@ -34,10 +34,11 @@ class DownloadCommand(private val core: Core) : Command {
                if (parameters.isEmpty()) {
                        return state
                }
-               val index = Ints.tryParse(parameters[0])
-               if (index != null && index < state.lastResults.size) {
-                       core.fetch(state.lastResults[index].bot(), state.lastResults[index].pack())
-               }
+               parameters
+                               .mapNotNull { Ints.tryParse(it) }
+                               .filter { it < state.lastResults.size }
+                               .map { state.lastResults[it] }
+                               .forEach { core.fetch(it.bot(), it.pack()) }
                return state
        }