/
cmd_bot_token_list.go
67 lines (57 loc) · 1.44 KB
/
cmd_bot_token_list.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
// 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/adamwalz/keybase-client/go/libcmdline"
"github.com/adamwalz/keybase-client/go/libkb"
)
func newCmdBotTokenList(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
cmd := cli.Command{
Name: "list",
Usage: "List bot tokens associated with this account",
Action: func(c *cli.Context) {
cl.ChooseCommand(NewCmdBotTokenListRunner(g), "list", c)
},
Flags: []cli.Flag{},
}
return cmd
}
type CmdBotTokenList struct {
libkb.Contextified
}
func NewCmdBotTokenListRunner(g *libkb.GlobalContext) *CmdBotTokenList {
return &CmdBotTokenList{
Contextified: libkb.NewContextified(g),
}
}
func (t *CmdBotTokenList) ParseArgv(ctx *cli.Context) (err error) {
nargs := len(ctx.Args())
if nargs != 0 {
return BadArgsError{"bot token list takes no arguments"}
}
return nil
}
func (t *CmdBotTokenList) Run() (err error) {
bcli, err := GetBotClient(t.G())
if err != nil {
return err
}
res, err := bcli.BotTokenList(context.TODO())
if err != nil {
return err
}
for _, row := range res {
_ = t.G().UI.GetTerminalUI().Output(row.Token.String() + "\n")
}
return nil
}
func (t *CmdBotTokenList) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
GpgKeyring: true,
KbKeyring: true,
API: true,
}
}