]> Sergey Matveev's repositories - btrtrc.git/blob - cmd/torrent/announce.go
cmd/torrent: Use anacrolix/args and merge several other cmds in as subcommands
[btrtrc.git] / cmd / torrent / announce.go
1 package main
2
3 import (
4         "fmt"
5
6         "github.com/davecgh/go-spew/spew"
7
8         "github.com/anacrolix/torrent"
9         "github.com/anacrolix/torrent/tracker"
10 )
11
12 type AnnounceCmd struct {
13         Tracker  string `arg:"positional"`
14         InfoHash torrent.InfoHash
15 }
16
17 func announceErr(flags AnnounceCmd) error {
18         response, err := tracker.Announce{
19                 TrackerUrl: flags.Tracker,
20                 Request: tracker.AnnounceRequest{
21                         InfoHash: flags.InfoHash,
22                         Port:     uint16(torrent.NewDefaultClientConfig().ListenPort),
23                 },
24         }.Do()
25         if err != nil {
26                 return fmt.Errorf("doing announce: %w", err)
27         }
28         spew.Dump(response)
29         return nil
30 }