Implement more issue filters #400
|
@ -32,11 +32,6 @@ var CmdIssuesList = cli.Command{
|
|||
|
||||
// RunIssuesList list issues
|
||||
func RunIssuesList(cmd *cli.Context) error {
|
||||
return DoIssuePRListing(cmd, gitea.IssueTypeIssue, issueFieldsFlag)
|
||||
}
|
||||
|
||||
// DoIssuePRListing lists issues + PRs of the repo in a generic way, and handles parsing of all filter flags.
|
||||
func DoIssuePRListing(cmd *cli.Context, kind gitea.IssueType, fieldsFlag *flags.CsvFlag) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
|
@ -72,7 +67,7 @@ func DoIssuePRListing(cmd *cli.Context, kind gitea.IssueType, fieldsFlag *flags.
|
|||
issues, _, err := ctx.Login.Client().ListRepoIssues(ctx.Owner, ctx.Repo, gitea.ListIssueOption{
|
||||
ListOptions: ctx.GetListOptions(),
|
||||
State: state,
|
||||
Type: kind,
|
||||
Type: gitea.IssueTypeIssue,
|
||||
KeyWord: ctx.String("keyword"),
|
||||
CreatedBy: ctx.String("author"),
|
||||
AssignedBy: ctx.String("assigned-to"),
|
||||
|
|
|
@ -6,17 +6,13 @@ package pulls
|
|||
|
||||
import (
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/cmd/issues"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var prFieldsFlag = flags.FieldsFlag(print.IssueFields, []string{
|
||||
"index", "title", "state", "author", "milestone", "updated",
|
||||
})
|
||||
|
||||
// CmdPullsList represents a sub command of issues to list pulls
|
||||
var CmdPullsList = cli.Command{
|
||||
Name: "list",
|
||||
|
@ -24,10 +20,32 @@ var CmdPullsList = cli.Command{
|
|||
Usage: "List pull requests of the repository",
|
||||
Description: `List pull requests of the repository`,
|
||||
Action: RunPullsList,
|
||||
Flags: append([]cli.Flag{prFieldsFlag}, flags.IssuePRFlags...),
|
||||
Flags: flags.IssuePRFlags,
|
||||
}
|
||||
|
||||
// RunPullsList return list of pulls
|
||||
func RunPullsList(cmd *cli.Context) error {
|
||||
return issues.DoIssuePRListing(cmd, gitea.IssueTypePull, prFieldsFlag)
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
state := gitea.StateOpen
|
||||
switch ctx.String("state") {
|
||||
case "all":
|
||||
state = gitea.StateAll
|
||||
case "open":
|
||||
state = gitea.StateOpen
|
||||
case "closed":
|
||||
state = gitea.StateClosed
|
||||
}
|
||||
|
||||
prs, _, err := ctx.Login.Client().ListRepoPullRequests(ctx.Owner, ctx.Repo, gitea.ListPullRequestsOptions{
|
||||
State: state,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
print.PullsList(prs, ctx.Output)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user