/
cmd_wot_react.go
116 lines (101 loc) · 2.59 KB
/
cmd_wot_react.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
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 client
import (
"errors"
"github.com/keybase/cli"
"github.com/adamwalz/keybase-client/go/libcmdline"
"github.com/adamwalz/keybase-client/go/libkb"
keybase1 "github.com/adamwalz/keybase-client/go/protocol/keybase1"
context "golang.org/x/net/context"
)
type CmdWotAccept struct {
Voucher string
libkb.Contextified
}
func newCmdWotAccept(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
flags := []cli.Flag{}
cmd := &CmdWotAccept{
Contextified: libkb.NewContextified(g),
}
return cli.Command{
Name: "accept",
Usage: "Accept a claim made by another user",
Description: "Accept a claim made by another user",
Action: func(c *cli.Context) {
cl.ChooseCommand(cmd, "accept", c)
},
Flags: flags,
}
}
func (c *CmdWotAccept) ParseArgv(ctx *cli.Context) error {
if len(ctx.Args()) != 1 {
return errors.New("accept requires a username")
}
c.Voucher = ctx.Args()[0]
return nil
}
func (c *CmdWotAccept) Run() error {
arg := keybase1.WotReactArg{
Voucher: c.Voucher,
Reaction: keybase1.WotReactionType_ACCEPT,
AllowEmptySigID: true, // Don't require the user to copy paste a sig ID
}
cli, err := GetWebOfTrustClient(c.G())
if err != nil {
return err
}
return cli.WotReact(context.Background(), arg)
}
func (c *CmdWotAccept) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
API: true,
KbKeyring: true,
}
}
/////////////////////////////////////////
type CmdWotReject struct {
Voucher string
libkb.Contextified
}
func newCmdWotReject(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
flags := []cli.Flag{}
cmd := &CmdWotReject{
Contextified: libkb.NewContextified(g),
}
return cli.Command{
Name: "reject",
Usage: "Reject a claim made by another user",
Description: "Reject a claim made by another user",
Action: func(c *cli.Context) {
cl.ChooseCommand(cmd, "reject", c)
},
Flags: flags,
Unlisted: true,
}
}
func (c *CmdWotReject) ParseArgv(ctx *cli.Context) error {
if len(ctx.Args()) != 1 {
return errors.New("reject requires a username")
}
c.Voucher = ctx.Args()[0]
return nil
}
func (c *CmdWotReject) Run() error {
arg := keybase1.WotReactArg{
Voucher: c.Voucher,
Reaction: keybase1.WotReactionType_REJECT,
AllowEmptySigID: true, // Don't require the user to copy paste a sig ID
}
cli, err := GetWebOfTrustClient(c.G())
if err != nil {
return err
}
return cli.WotReact(context.Background(), arg)
}
func (c *CmdWotReject) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
API: true,
KbKeyring: true,
}
}