From: Matt Joiner Date: Thu, 14 Aug 2025 07:13:48 +0000 (+1000) Subject: Small improvements to cmd/torrent2 metainfo pprint X-Git-Tag: v1.59.0~2^2~2 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=55ef14362847e64d24ae6b6395b1ce2d7299c3ce;p=btrtrc.git Small improvements to cmd/torrent2 metainfo pprint --- diff --git a/cmd/torrent2/main.go b/cmd/torrent2/main.go index b215ee1c..ff26dea5 100644 --- a/cmd/torrent2/main.go +++ b/cmd/torrent2/main.go @@ -72,6 +72,8 @@ func mainErr() error { assertOk(err) info, err := mi.UnmarshalInfo() assertOk(err) + fmt.Printf("name: %q\n", info.Name) + fmt.Printf("# files:\n") files := info.UpvertedFiles() pieceIndex := 0 for _, f := range files { @@ -82,9 +84,14 @@ func mainErr() error { hash = a.HexString() } fmt.Printf( - "%s: %q: pieces (%v-%v)\n", + "%s: %v: pieces (%v-%v)\n", hash, - f.BestPath(), + func() any { + if info.IsDir() { + return fmt.Sprintf("%q", f.BestPath()) + } + return "(single file torrent)" + }(), pieceIndex, endIndex-1, )