forked from gochain/gochain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (42 loc) · 831 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"flag"
"fmt"
"os"
)
func main() {
if err := run(os.Args[1:]); err == flag.ErrHelp {
os.Exit(1)
} else if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func run(args []string) error {
var cmd string
if len(args) > 0 {
cmd, args = args[0], args[1:]
}
switch cmd {
case "", "help":
PrintUsage()
return nil
case "check":
return NewCheckCommand().Run(args)
case "keys":
return NewKeysCommand().Run(args)
default:
return fmt.Errorf("unknown command: %q", cmd)
}
}
func PrintUsage() {
fmt.Fprintln(os.Stderr, `
This is a tool for inspecting and working with ethdb database files.
Usage:
gochain-ethdb command [arguments]
The commands are:
check verify integrity of a segment
help print this screen
keys dump all keys for a table
`[1:])
}