mirror of
https://gitea.com/jolheiser/sip
synced 2024-11-22 19:51:58 +01:00
5b7b970a06
Signed-off-by: jolheiser <john.olheiser@gmail.com>
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package cmd
|
|
|
|
import (
|
|
"gitea.com/jolheiser/beaver"
|
|
"gitea.com/jolheiser/beaver/color"
|
|
"gitea.com/jolheiser/gitea-sdk"
|
|
"github.com/antihax/optional"
|
|
"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 {
|
|
auth := getAuth(ctx.String("login"))
|
|
client := getClient(ctx.String("url"))
|
|
|
|
issues, err := getIssues(auth, client, ctx.String("owner"), ctx.String("repo"), &gitea.IssueListIssuesOpts{
|
|
State: optional.NewString("open"),
|
|
Type_: optional.NewString("issues"),
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
pulls, err := getPulls(auth, client, ctx.String("owner"), ctx.String("repo"), &gitea.RepoListPullRequestsOpts{
|
|
State: optional.NewString("open"),
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
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(len(issues))))
|
|
beaver.Infof("Open Pulls: %s", color.New(color.FgYellow).Format(strconv.Itoa(len(pulls))))
|
|
|
|
return nil
|
|
}
|