cmd/torrent-metainfo-pprint: Output JSON instead
This commit is contained in:
parent
b5ee4f602d
commit
348c6406eb
|
@ -1,9 +1,11 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/anacrolix/torrent/metainfo"
|
||||
)
|
||||
|
@ -19,8 +21,14 @@ func main() {
|
|||
}
|
||||
if *name {
|
||||
fmt.Printf("%s\n", metainfo.Info.Name)
|
||||
} else {
|
||||
fmt.Printf("%+#v\n", metainfo)
|
||||
continue
|
||||
}
|
||||
d := map[string]interface{}{
|
||||
"Name": metainfo.Info.Name,
|
||||
"NumPieces": metainfo.Info.NumPieces(),
|
||||
}
|
||||
b, _ := json.MarshalIndent(d, "", " ")
|
||||
os.Stdout.Write(b)
|
||||
}
|
||||
os.Stdout.WriteString("\n")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue