1
0
mirror of https://gitea.com/jolheiser/sip synced 2024-11-26 07:33:48 +01:00
sip/cmd/repo.go
jolheiser 58fe648da6
More work
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-02-15 23:51:14 -06:00

43 lines
1.1 KiB
Go

package cmd
import (
"code.gitea.io/sdk/gitea"
"gitea.com/jolheiser/beaver"
"gitea.com/jolheiser/beaver/color"
"gitea.com/jolheiser/tea/modules/sdk"
"github.com/urfave/cli/v2"
"strconv"
)
var Repo = cli.Command{
Name: "repo",
Usage: "Commands for interacting with a Gitea repository",
Action: doRepo,
}
func doRepo(ctx *cli.Context) error {
client := getClient(ctx)
issues, err := sdk.GetIssues(client, ctx.String("owner"), ctx.String("repo"), gitea.ListIssueOption{State: "open"})
if err != nil {
return err
}
var issueCount, pullCount int
for _, issue := range issues {
if issue.PullRequest != nil {
pullCount++
continue
}
issueCount++
}
beaver.Infof("Repository: %s", color.New(color.FgYellow).Format(ctx.String("owner")+"/"+ctx.String("repo")))
beaver.Infof("URL: %s", color.New(color.FgYellow).Format(ctx.String("url")+"/"+ctx.String("owner")+"/"+ctx.String("repo")))
beaver.Info()
beaver.Infof("Open Issues: %s", color.New(color.FgYellow).Format(strconv.Itoa(issueCount)))
beaver.Infof("Open Pulls: %s", color.New(color.FgYellow).Format(strconv.Itoa(pullCount)))
return nil
}