This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
issue.go
68 lines (63 loc) · 1.63 KB
/
issue.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
68
package commands
import (
"fmt"
"github.com/gookit/color"
"github.com/gosuri/uitable"
"github.com/spf13/cobra"
"github.com/xanzy/go-gitlab"
"glab/internal/git"
"glab/internal/manip"
"strings"
)
func displayAllIssues(m []*gitlab.Issue) {
if len(m) > 0 {
fmt.Printf("\nShowing issues %d of %d on %s\n\n", len(m), len(m), git.GetRepo())
table := uitable.New()
table.MaxColWidth = 70
for _, issue := range m {
var labels string
for _, l := range issue.Labels {
labels += " " + l + ","
}
labels = strings.Trim(labels, ", ")
if labels != ""{
labels = "(" + labels + ")"
}
var issueID string
duration := manip.TimeAgo(*issue.CreatedAt)
if issue.State == "opened" {
issueID = color.Sprintf("<green>#%d</>", issue.IID)
} else {
issueID = color.Sprintf("<red>#%d</>", issue.IID)
}
table.AddRow(issueID, issue.Title, color.Cyan.Sprintf(labels), color.Gray.Sprintf(duration))
}
fmt.Println(table)
} else {
fmt.Println("No Issues available on " + git.GetRepo())
}
}
func displayIssue(hm *gitlab.Issue) {
duration := manip.TimeAgo(*hm.CreatedAt)
if hm.State == "opened" {
color.Printf("<green>#%d</> %s <magenta>(%s)</>\n", hm.IID, hm.Title, duration)
} else {
color.Printf("<red>#%d</> %s <magenta>(%s)</>\n", hm.IID, hm.Title, duration)
}
fmt.Println(hm.WebURL)
}
// mrCmd is merge request command
var issueCmd = &cobra.Command{
Use: "issue <command> [flags]",
Short: `Create, view and manage remote issues`,
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 || len(args) > 2 {
cmd.Help()
return
}
},
}
func init() {
RootCmd.AddCommand(issueCmd)
}