-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.go
More file actions
116 lines (85 loc) · 2.1 KB
/
cli.go
File metadata and controls
116 lines (85 loc) · 2.1 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package main
/*
Two main files are ../fuse.go and ../fs/serve.go
*/
import (
"flag"
. "moss/ubi"
"os"
)
var (
err error
debug = false
)
//=====================================================================
func main() {
Debug = false
flag.BoolVar(&AsyncPull, "a", AsyncPull, "reset ubi")
flag.BoolVar(&Debug, "d", false, "toggle debug")
flag.StringVar(&ServerAddress, "s", ServerAddress, "<server>:<port>")
flag.StringVar(&PublicKeyFile, "p", PublicKeyFile, "public key file")
flag.StringVar(&PrivateKeyFile, "q", PrivateKeyFile, "public key file")
flag.Parse()
args := flag.Args()
UbiServers = []string{ServerAddress}
StartConnections()
PrintDebug("debug %v, addr: %q, args: %v\n", Debug, ServerAddress, args)
// Log.ClientDebug("debug %v, addr: %q, args: %v\n", Debug, ServerAddress, args)
if len(args) == 0 {
usage(args)
}
cmd, args := args[0], args[1:]
lst, _ := os.ReadFile("/tmp/.last")
LastSig = string(lst)
PrintDebug("last is %q\n", LastSig)
if debug {
Log.ClientDebug("running %q\n", cmd)
}
switch cmd {
case "build":
CmdBuild()
case "path":
PrintAssert(len(args) >= 2, "path <root> <path desc>\n")
if debug {
Log.ClientDebug("sig: %q, path: %q\n", args[0], args[1])
}
CmdPath(args[0], args[1])
case "put":
CmdPut(args[0])
case "get":
PrintAssert(len(args) >= 2, " <sig> <server>\n")
CmdGet(args[0], args[1], false)
case "dump":
// PrintAssert(len(args) >= 1, "dump <sig>\n")
CmdDesc(args[0], true)
case "desc":
// PrintAssert(len(args) >= 1, "desc <sig>\n")
CmdDesc(args[0], false)
case "list":
CmdList()
case "pull":
PrintAssert(len(args) >= 1, "pull <server>\n")
CmdPull(args[0])
case "genkeys":
CmdGenKeys()
case "binding":
if (PrivateKeyFile == "") || (PublicKeyFile == "") || (len(args) < 2) {
usage(args)
}
CmdBinding(args[0], args[1])
case "sign":
if (PrivateKeyFile == "") || (len(args) < 1) {
usage(args)
}
CmdSignJSON(args[0])
case "verify":
CmdVerifyJSON(args[0])
case "verifybinding":
CmdVerifyBinding(args[0])
default:
usage(args)
}
}
func usage(args []string) {
PrintAlways("look up\n")
}