cmd/torrent create: Add piece length and private options
This commit is contained in:
parent
fe4c930bf5
commit
240b42fd56
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"github.com/anacrolix/bargle"
|
||||
"github.com/anacrolix/tagflag"
|
||||
"github.com/anacrolix/torrent/bencode"
|
||||
"github.com/anacrolix/torrent/metainfo"
|
||||
"os"
|
||||
|
@ -20,8 +21,10 @@ func create() (cmd bargle.Command) {
|
|||
Comment string `name:"t" help:"comment"`
|
||||
CreatedBy string `name:"c" help:"created by"`
|
||||
InfoName *string `name:"i" help:"override info name (defaults to ROOT)"`
|
||||
PieceLength tagflag.Bytes
|
||||
Url []string `name:"u" help:"add webseed url"`
|
||||
Root string `arg:"positional"`
|
||||
Private *bool
|
||||
Root string `arg:"positional"`
|
||||
}
|
||||
cmd = bargle.FromStruct(&args)
|
||||
cmd.Desc = "Creates a torrent metainfo for the file system rooted at ROOT, and outputs it to stdout"
|
||||
|
@ -43,7 +46,10 @@ func create() (cmd bargle.Command) {
|
|||
mi.CreatedBy = args.CreatedBy
|
||||
}
|
||||
mi.UrlList = args.Url
|
||||
info := metainfo.Info{}
|
||||
info := metainfo.Info{
|
||||
PieceLength: args.PieceLength.Int64(),
|
||||
Private: args.Private,
|
||||
}
|
||||
err = info.BuildFromFilePath(args.Root)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
2
go.mod
2
go.mod
|
@ -51,7 +51,7 @@ require (
|
|||
require (
|
||||
github.com/alecthomas/atomic v0.1.0-alpha2 // indirect
|
||||
github.com/alexflint/go-scalar v1.1.0 // indirect
|
||||
github.com/anacrolix/bargle v0.0.0-20220622082028-6c0bfc8b614d // indirect
|
||||
github.com/anacrolix/bargle v0.0.0-20220630015206-d7a4d433886a // indirect
|
||||
github.com/anacrolix/mmsg v1.0.0 // indirect
|
||||
github.com/anacrolix/stm v0.4.0 // indirect
|
||||
github.com/benbjohnson/immutable v0.3.0 // indirect
|
||||
|
|
4
go.sum
4
go.sum
|
@ -68,6 +68,10 @@ github.com/anacrolix/bargle v0.0.0-20220620083758-c3885e1796d1 h1:RijTNFCxug0EBO
|
|||
github.com/anacrolix/bargle v0.0.0-20220620083758-c3885e1796d1/go.mod h1:cC/kX8wL4i1n+63lOrXhPQQlsoxCo0EqV88fGExQwcY=
|
||||
github.com/anacrolix/bargle v0.0.0-20220622082028-6c0bfc8b614d h1:eSBxjJUsa4p5lCn8mlp6gOdzhZYZxqr4YHPk8Uwn1iQ=
|
||||
github.com/anacrolix/bargle v0.0.0-20220622082028-6c0bfc8b614d/go.mod h1:9xUiZbkh+94FbiIAL1HXpAIBa832f3Mp07rRPl5c5RQ=
|
||||
github.com/anacrolix/bargle v0.0.0-20220627055849-08d7fa720ece h1:QPZd4ViWNy2uxIbrj1fIhvLxpe27GrnzaaVHGfY6Aac=
|
||||
github.com/anacrolix/bargle v0.0.0-20220627055849-08d7fa720ece/go.mod h1:9xUiZbkh+94FbiIAL1HXpAIBa832f3Mp07rRPl5c5RQ=
|
||||
github.com/anacrolix/bargle v0.0.0-20220630015206-d7a4d433886a h1:KCP9QvHlLoUQBOaTf/YCuOzG91Ym1cPB6S68O4Q3puo=
|
||||
github.com/anacrolix/bargle v0.0.0-20220630015206-d7a4d433886a/go.mod h1:9xUiZbkh+94FbiIAL1HXpAIBa832f3Mp07rRPl5c5RQ=
|
||||
github.com/anacrolix/chansync v0.3.0 h1:lRu9tbeuw3wl+PhMu/r+JJCRu5ArFXIluOgdF0ao6/U=
|
||||
github.com/anacrolix/chansync v0.3.0/go.mod h1:DZsatdsdXxD0WiwcGl0nJVwyjCKMDv+knl1q2iBjA2k=
|
||||
github.com/anacrolix/dht/v2 v2.18.0 h1:btjVjzjKqO5nKGbJHJ2UmuwiRx+EgX3e+OCHC9+WRz8=
|
||||
|
|
Loading…
Reference in New Issue