1
1
Fork 0
mirror of https://gitea.com/gitea/tea synced 2024-04-30 05:45:20 +02:00
tea/cmd/issues.go
Norwin 9efee7bf99 Add `tea issues --fields`, allow printing labels (#312)
generalize list printing with dynamic fields

refactor print.IssuesList to use tableFromItems()

preparatory refactor

print.IssuesList: allow printing labels

move formatters to formatters.go

expose more printable fields on issue

add generic flags.FieldsFlag

add fields flag to tea issues, tea ms issues

validate provided fields

add strict username, or formatted user fields

change default fields

tea issues -> replace updated with labels
tea ms issues -> replace author with labels, reorder

Validate provided fields

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/312
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-21 23:41:07 +08:00

56 lines
1.3 KiB
Go

// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package cmd
import (
"code.gitea.io/tea/cmd/issues"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/utils"
"github.com/urfave/cli/v2"
)
// CmdIssues represents to login a gitea server.
var CmdIssues = cli.Command{
Name: "issues",
Aliases: []string{"issue", "i"},
Category: catEntities,
Usage: "List, create and update issues",
Description: "List, create and update issues",
ArgsUsage: "[<issue index>]",
Action: runIssues,
Subcommands: []*cli.Command{
&issues.CmdIssuesList,
&issues.CmdIssuesCreate,
&issues.CmdIssuesReopen,
&issues.CmdIssuesClose,
},
Flags: issues.CmdIssuesList.Flags,
}
func runIssues(ctx *cli.Context) error {
if ctx.Args().Len() == 1 {
return runIssueDetail(ctx, ctx.Args().First())
}
return issues.RunIssuesList(ctx)
}
func runIssueDetail(cmd *cli.Context, index string) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
idx, err := utils.ArgToIndex(index)
if err != nil {
return err
}
issue, _, err := ctx.Login.Client().GetIssue(ctx.Owner, ctx.Repo, idx)
if err != nil {
return err
}
print.IssueDetails(issue)
return nil
}