cmd/torrent: Add file pick flag

This commit is contained in:
Matt Joiner 2020-12-09 20:00:42 +11:00
parent c0db7e1c26
commit e67fe7ddca
1 changed files with 12 additions and 1 deletions

View 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"`
}