/
cmd_badge.go
59 lines (51 loc) · 1.25 KB
/
cmd_badge.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
// Copyright 2017 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package client
import (
"encoding/json"
"github.com/keybase/cli"
"github.com/keybase/client/go/libcmdline"
"github.com/keybase/client/go/libkb"
"golang.org/x/net/context"
)
type CmdBadge struct {
libkb.Contextified
}
func (c *CmdBadge) ParseArgv(ctx *cli.Context) error {
return nil
}
func (c *CmdBadge) Run() error {
cli, err := GetBadgerClient(c.G())
if err != nil {
return err
}
ctx := context.Background()
state, err := cli.GetBadgeState(ctx)
if err != nil {
return err
}
b, err := json.Marshal(state)
if err != nil {
return err
}
return c.G().UI.GetTerminalUI().OutputDesc(OutputDescriptorBadgeDump, string(b)+"\n")
}
func NewCmdBadgeRunner(g *libkb.GlobalContext) *CmdBadge {
return &CmdBadge{Contextified: libkb.NewContextified(g)}
}
func NewCmdBadge(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "badge",
Usage: "Get the client's badge state",
Action: func(c *cli.Context) {
cl.ChooseCommand(NewCmdBadgeRunner(g), "badge", c)
},
Flags: []cli.Flag{},
}
}
func (c *CmdBadge) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
API: true,
}
}