Fix flags added multiple times (#2914)

Closes https://github.com/woodpecker-ci/woodpecker/issues/2912

Global flags should not be added to the commands/subscommands, only
globally.
This commit is contained in:
qwerty287
2023-12-08 09:36:53 +01:00
committed by GitHub
parent adb2c82790
commit a796885ad4
52 changed files with 55 additions and 120 deletions

View File

@@ -16,15 +16,12 @@ package cron
import (
"github.com/urfave/cli/v2"
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
)
// Command exports the cron command set.
var Command = &cli.Command{
Name: "cron",
Usage: "manage cron jobs",
Flags: common.GlobalFlags,
Subcommands: []*cli.Command{
cronCreateCmd,
cronDeleteCmd,

View File

@@ -30,7 +30,7 @@ var cronCreateCmd = &cli.Command{
Usage: "add a cron job",
ArgsUsage: "[repo-id|repo-full-name]",
Action: cronCreate,
Flags: append(common.GlobalFlags,
Flags: []cli.Flag{
common.RepoFlag,
&cli.StringFlag{
Name: "name",
@@ -47,7 +47,7 @@ var cronCreateCmd = &cli.Command{
Required: true,
},
common.FormatFlag(tmplCronList, true),
),
},
}
func cronCreate(c *cli.Context) error {

View File

@@ -29,7 +29,7 @@ var cronInfoCmd = &cli.Command{
Usage: "display info about a cron job",
ArgsUsage: "[repo-id|repo-full-name]",
Action: cronInfo,
Flags: append(common.GlobalFlags,
Flags: []cli.Flag{
common.RepoFlag,
&cli.StringFlag{
Name: "id",
@@ -37,7 +37,7 @@ var cronInfoCmd = &cli.Command{
Required: true,
},
common.FormatFlag(tmplCronList, true),
),
},
}
func cronInfo(c *cli.Context) error {

View File

@@ -29,10 +29,10 @@ var cronListCmd = &cli.Command{
Usage: "list cron jobs",
ArgsUsage: "[repo-id|repo-full-name]",
Action: cronList,
Flags: append(common.GlobalFlags,
Flags: []cli.Flag{
common.RepoFlag,
common.FormatFlag(tmplCronList, true),
),
},
}
func cronList(c *cli.Context) error {

View File

@@ -28,14 +28,14 @@ var cronDeleteCmd = &cli.Command{
Usage: "remove a cron job",
ArgsUsage: "[repo-id|repo-full-name]",
Action: cronDelete,
Flags: append(common.GlobalFlags,
Flags: []cli.Flag{
common.RepoFlag,
&cli.StringFlag{
Name: "id",
Usage: "cron id",
Required: true,
},
),
},
}
func cronDelete(c *cli.Context) error {

View File

@@ -30,7 +30,7 @@ var cronUpdateCmd = &cli.Command{
Usage: "update a cron job",
ArgsUsage: "[repo-id|repo-full-name]",
Action: cronUpdate,
Flags: append(common.GlobalFlags,
Flags: []cli.Flag{
common.RepoFlag,
&cli.StringFlag{
Name: "id",
@@ -50,7 +50,7 @@ var cronUpdateCmd = &cli.Command{
Usage: "cron schedule",
},
common.FormatFlag(tmplCronList, true),
),
},
}
func cronUpdate(c *cli.Context) error {