]> Sergey Matveev's repositories - btrtrc.git/commitdiff
cmd/torrent: Add file pick flag
authorMatt Joiner <anacrolix@gmail.com>
Wed, 9 Dec 2020 09:00:42 +0000 (20:00 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 9 Dec 2020 09:00:42 +0000 (20:00 +1100)
cmd/torrent/main.go

index fb0b20750e80a673d2e6c58e87c7d85d5dbad759..ebb0cdfd92b3bd7392dd188f54afe5b73929ef0f 100644 (file)
@@ -133,7 +133,17 @@ func addTorrents(client *torrent.Client) error {
                t.AddPeers(testPeers)
                go func() {
                        <-t.GotInfo()
-                       t.DownloadAll()
+                       if len(flags.File) == 0 {
+                               t.DownloadAll()
+                       } else {
+                               for _, f := range t.Files() {
+                                       for _, fileArg := range flags.File {
+                                               if f.DisplayPath() == fileArg {
+                                                       f.Download()
+                                               }
+                                       }
+                               }
+                       }
                }()
        }
        return nil
@@ -185,6 +195,7 @@ type DownloadCmd struct {
        Ipv6 bool
        Pex  bool
 
+       File    []string
        Torrent []string `arity:"+" help:"torrent file path or magnet uri" arg:"positional"`
 }