cmd/torrent-metainfo-pprint: Output JSON instead
This commit is contained in:
parent
b5ee4f602d
commit
348c6406eb
|
@ -1,9 +1,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/anacrolix/torrent/metainfo"
|
"github.com/anacrolix/torrent/metainfo"
|
||||||
)
|
)
|
||||||
|
@ -19,8 +21,14 @@ func main() {
|
||||||
}
|
}
|
||||||
if *name {
|
if *name {
|
||||||
fmt.Printf("%s\n", metainfo.Info.Name)
|
fmt.Printf("%s\n", metainfo.Info.Name)
|
||||||
} else {
|
continue
|
||||||
fmt.Printf("%+#v\n", metainfo)
|
|
||||||
}
|
}
|
||||||
|
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