-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmd_favorite.go
55 lines (47 loc) · 1.28 KB
/
cmd_favorite.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
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package client
import (
"fmt"
"path/filepath"
"github.com/keybase/cli"
"github.com/keybase/client/go/libcmdline"
keybase1 "github.com/keybase/client/go/protocol"
)
func NewCmdFavorite(cl *libcmdline.CommandLine) cli.Command {
return cli.Command{
Name: "favorite",
ArgumentHelp: "[arguments...]",
Usage: "Manage favorites",
Subcommands: []cli.Command{
NewCmdFavoriteAdd(cl),
NewCmdFavoriteRemove(cl),
NewCmdFavoriteList(cl),
},
}
}
// ParseTLF takes keybase paths like
//
// /keybase/public/patrick,chris
// /keybase/private/patrick,maxtaco@twitter
// public/patrick,jack
// /public/patrick,chris,sam
//
// and creates suitable folders with the name portion and the
// private flag set correctly.
func ParseTLF(path string) (keybase1.Folder, error) {
dir, name := filepath.Split(path)
var f keybase1.Folder
// get the last element of the directory, which should be public or private
acc := filepath.Base(dir)
switch acc {
case "public":
f.Private = false
case "private":
f.Private = true
default:
return f, fmt.Errorf("folder path needs to contain public or private subdirectory")
}
f.Name = name
return f, nil
}