forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_favorite_list.go
66 lines (56 loc) · 1.34 KB
/
cmd_favorite_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
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package client
import (
"errors"
"path/filepath"
"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"
)
type CmdFavoriteList struct{}
func NewCmdFavoriteList(cl *libcmdline.CommandLine) cli.Command {
return cli.Command{
Name: "list",
Usage: "List favorites",
Action: func(c *cli.Context) {
cl.ChooseCommand(&CmdFavoriteList{}, "add", c)
},
}
}
func (c *CmdFavoriteList) ParseArgv(ctx *cli.Context) error {
if len(ctx.Args()) != 0 {
return errors.New("Favorite list doesn't take any arguments")
}
return nil
}
func (c *CmdFavoriteList) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
API: true,
}
}
func (c *CmdFavoriteList) Run() error {
arg := keybase1.FavoriteListArg{}
folders, err := list(arg)
if err != nil {
return err
}
for _, f := range folders {
acc := "public"
if f.Private {
acc = "private"
}
GlobUI.Println(filepath.Join(acc, f.Name))
}
return nil
}
func list(arg keybase1.FavoriteListArg) ([]keybase1.Folder, error) {
cli, err := GetFavoriteClient()
if err != nil {
return nil, err
}
return cli.FavoriteList(context.TODO(), 0)
}