Repository navigation
Expand file tree
/
Copy pathcmd_bot_token_delete.go
More file actions
75 lines (65 loc) · 1.61 KB
/
Copy pathcmd_bot_token_delete.go
File metadata and controls
75 lines (65 loc) · 1.61 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
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package client
import (
"golang.org/x/net/context"
"github.com/keybase/cli"
"github.com/keybase/client/go/libcmdline"
"github.com/keybase/client/go/libkb"
keybase1 "github.com/keybase/client/go/protocol/keybase1"
)
func newCmdBotTokenDelete(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
cmd := cli.Command{
Name: "delete",
Usage: "Delete a bot token",
Action: func(c *cli.Context) {
cl.ChooseCommand(NewCmdBotTokenDeleteRunner(g), "delete", c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "t, token",
Usage: "Specify a bot token",
},
},
}
return cmd
}
type CmdBotTokenDelete struct {
libkb.Contextified
token keybase1.BotToken
}
func NewCmdBotTokenDeleteRunner(g *libkb.GlobalContext) *CmdBotTokenDelete {
return &CmdBotTokenDelete{
Contextified: libkb.NewContextified(g),
}
}
func (t *CmdBotTokenDelete) ParseArgv(ctx *cli.Context) (err error) {
nargs := len(ctx.Args())
if nargs != 0 {
return BadArgsError{"bot token delete takes no arguments"}
}
t.token, err = keybase1.NewBotToken(ctx.String("token"))
if err != nil {
return BadArgsError{"bad bot token"}
}
return nil
}
func (t *CmdBotTokenDelete) Run() (err error) {
bcli, err := GetBotClient(t.G())
if err != nil {
return err
}
err = bcli.BotTokenDelete(context.TODO(), t.token)
if err != nil {
return err
}
return nil
}
func (t *CmdBotTokenDelete) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
GpgKeyring: true,
KbKeyring: true,
API: true,
}
}