Skip to content

Commit f0daabe

Browse files
Add cmd/gots-dump tool
This produces output similar to `ots info`, dumping the timestamp tree of a detached timestamp file.
1 parent 01b0c9b commit f0daabe

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
.PHONY: test
1+
.PHONY: build test
22

33
MYPKG=$(shell go list ./... | grep -v /vendor/)
44

5+
build:
6+
go build $(MYPKG)
7+
58
test:
69
go test $(MYPKG)

cmd/gots-dump/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gots-dump

cmd/gots-dump/main.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
"log"
7+
"os"
8+
9+
"github.com/BlockchainSource/go-opentimestamps/opentimestamps"
10+
)
11+
12+
func main() {
13+
flag.Parse()
14+
path := flag.Arg(0)
15+
f, err := os.Open(path)
16+
if err != nil {
17+
log.Fatalf("error opening file: %v", err)
18+
}
19+
20+
ts, err := opentimestamps.NewDetachedTimestampFile(f)
21+
if err != nil {
22+
log.Fatalf(
23+
"error decoding detached timestamp %s: %v",
24+
path, err,
25+
)
26+
}
27+
28+
fmt.Println(ts.Dump())
29+
}

0 commit comments

Comments
 (0)