package app import ( "context" "fmt" c "cnb.cool/cnb/go-cnb/cnb" "cnb.cool/looc/git-cnb/cnb" "cnb.cool/looc/git-cnb/ui" "github.com/spf13/cobra" ) var IssuesCmd = &cobra.Command{ Use: "issue", Short: "print issues of this repo", Long: "print issues of this repo", Run: func(cmd *cobra.Command, args []string) { List(cmd.Context()) }, } func List(ctx context.Context) { me, err := cnb.Me(ctx, Client) if err != nil { ui.ErrorWithExit(err.Error()) } opts := &c.IssueListOptions{ State: c.IssueStateOpen, Assignees: me.UserName, } issues, err := cnb.ListIssues(ctx, Client, Repo, opts) if err != nil { ui.ErrorWithExit(err.Error()) } title := []interface{}{"Number", "Title", "Author", "Priority"} items := make([][]interface{}, 0) for _, issue := range issues { items = append(items, []interface{}{ fmt.Sprintf("#%s", issue.Number), issue.Title, issue.Author.NickName, issue.Priority}) } ui.Table(title, items) }