-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
71 lines (59 loc) · 1.24 KB
/
main.go
File metadata and controls
71 lines (59 loc) · 1.24 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
package main
import (
"errors"
"os"
"strings"
"gopkg.in/urfave/cli.v2"
)
const missingRepo = "Error: missing repository."
const githubAPIRoot = "https://api.github.com/repos/"
type GithubLabel struct {
Name string `json:"name"`
Color string `json:"color"`
}
type GithubLabels []GithubLabel
func parseRepository(repository string) (string, string, error) {
res := strings.Split(repository, "/")
if len(res) != 2 {
return "", "", errors.New("Invalid repository name")
}
return res[0], res[1], nil
}
func main() {
app := cli.NewApp()
app.Name = "github-labels"
app.Usage = "Manage github labels easily"
app.Version = "0.1.0"
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "token",
Aliases: []string{"t"},
Usage: "Github Token (Mandatory)",
},
}
app.Commands = []*cli.Command{
{
Name: "list",
Usage: "Print labels from a repository",
Action: List,
},
{
Name: "set",
Usage: "Set repository labels from a file",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "labels",
Aliases: []string{"l"},
Usage: "Labels json file",
},
},
Action: Set,
},
{
Name: "import",
Usage: "Import labels from a repository to another",
Action: Import,
},
}
app.Run(os.Args)
}