mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 09:58:29 +02:00
Add --fields
to notification & milestone listings (#422)
Together with #415 this finally adds the field flag to all entity listings. closes #342 ### ⚠️ breaking changes ⚠️ This changes the column names of `tea milestones ls`: ```diff - TITLE | OPEN/CLOSED ISSUES | DUEDATE + TITLE | ITEMS | DUEDATE ``` Co-authored-by: Norwin <git@nroo.de> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/422 Reviewed-by: delvh <dev.lh@web.de> Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: Norwin <noerw@noreply.gitea.io> Co-committed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
@ -13,6 +13,10 @@ import (
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var fieldsFlag = flags.FieldsFlag(print.MilestoneFields, []string{
|
||||
"title", "items", "duedate",
|
||||
})
|
||||
|
||||
// CmdMilestonesList represents a sub command of milestones to list milestones
|
||||
var CmdMilestonesList = cli.Command{
|
||||
Name: "list",
|
||||
@ -22,6 +26,7 @@ var CmdMilestonesList = cli.Command{
|
||||
ArgsUsage: " ", // command does not accept arguments
|
||||
Action: RunMilestonesList,
|
||||
Flags: append([]cli.Flag{
|
||||
fieldsFlag,
|
||||
&cli.StringFlag{
|
||||
Name: "state",
|
||||
Usage: "Filter by milestone state (all|open|closed)",
|
||||
@ -37,10 +42,18 @@ func RunMilestonesList(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
fields, err := fieldsFlag.GetValues(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
state := gitea.StateOpen
|
||||
switch ctx.String("state") {
|
||||
case "all":
|
||||
state = gitea.StateAll
|
||||
if !cmd.IsSet("fields") { // add to default fields
|
||||
fields = append(fields, "state")
|
||||
}
|
||||
case "closed":
|
||||
state = gitea.StateClosed
|
||||
}
|
||||
@ -55,6 +68,6 @@ func RunMilestonesList(cmd *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
print.MilestonesList(milestones, ctx.Output, state)
|
||||
print.MilestonesList(milestones, ctx.Output, fields)
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user