forked from JonathanLogan/codechain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodechain.go
75 lines (71 loc) · 2.13 KB
/
codechain.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// codechain establishes code trust through hash chains.
package main
import (
"flag"
"fmt"
"os"
"github.com/frankbraun/codechain/command"
"github.com/frankbraun/codechain/util/homedir"
)
func usage() {
cmd := os.Args[0]
fmt.Fprintf(os.Stderr, "Usage: %s treehash [-l]\n", cmd)
fmt.Fprintf(os.Stderr, " %s keygen [-s seckey.bin]\n", cmd)
fmt.Fprintf(os.Stderr, " %s keyfile [-l] -s seckey.bin [-c]\n", cmd)
fmt.Fprintf(os.Stderr, " %s start -s seckey.bin\n", cmd)
fmt.Fprintf(os.Stderr, " %s publish [-s seckey.bin]\n", cmd)
fmt.Fprintf(os.Stderr, " %s review [-a] [-d] [-s seckey.bin] [treehash]\n", cmd)
fmt.Fprintf(os.Stderr, " %s addkey [-w] pubkey signature [comment]\n", cmd)
fmt.Fprintf(os.Stderr, " %s remkey pubkey\n", cmd)
fmt.Fprintf(os.Stderr, " %s sigctl -m\n", cmd)
fmt.Fprintf(os.Stderr, " %s createdist -f dist.tar.gz\n", cmd)
fmt.Fprintf(os.Stderr, " %s apply\n", cmd)
fmt.Fprintf(os.Stderr, " %s status\n", cmd)
fmt.Fprintf(os.Stderr, " %s cleanslate\n", cmd)
os.Exit(2)
}
func main() {
if len(os.Args) < 2 {
usage()
}
argv0 := os.Args[0] + " " + os.Args[1]
args := os.Args[2:]
var err error
switch os.Args[1] {
case "treehash":
err = command.TreeHash(argv0, args...)
case "keygen":
err = command.KeyGen(homedir.Codechain(), argv0, args...)
case "keyfile":
err = command.KeyFile(homedir.Codechain(), argv0, args...)
case "start":
err = command.Start(argv0, args...)
case "publish":
err = command.Publish(argv0, args...)
case "review":
err = command.Review(argv0, args...)
case "addkey":
err = command.AddKey(argv0, args...)
case "remkey":
err = command.RemKey(argv0, args...)
case "sigctl":
err = command.SigCtl(argv0, args...)
case "createdist":
err = command.CreateDist(argv0, args...)
case "apply":
err = command.Apply(argv0, args...)
case "status":
err = command.Status(argv0, args...)
case "cleanslate":
err = command.CleanSlate(argv0, args...)
default:
usage()
}
if err != nil {
if err != flag.ErrHelp {
fmt.Fprintf(os.Stderr, "%s: error: %s\n", os.Args[0], err)
os.Exit(1)
}
os.Exit(2)
}
}