2020-09-30 01:11:33 -04:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2023-09-07 21:40:02 -04:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-09-30 01:11:33 -04:00
|
|
|
|
|
|
|
package labels
|
|
|
|
|
|
|
|
import (
|
2021-06-22 10:23:09 -04:00
|
|
|
"code.gitea.io/tea/cmd/flags"
|
2020-12-15 12:38:22 -05:00
|
|
|
"code.gitea.io/tea/modules/context"
|
2020-09-30 01:11:33 -04:00
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CmdLabelDelete represents a sub command of labels to delete label.
|
|
|
|
var CmdLabelDelete = cli.Command{
|
|
|
|
Name: "delete",
|
2020-12-16 11:47:40 -05:00
|
|
|
Aliases: []string{"rm"},
|
2020-09-30 01:11:33 -04:00
|
|
|
Usage: "Delete a label",
|
|
|
|
Description: `Delete a label`,
|
2022-09-13 14:14:02 -04:00
|
|
|
ArgsUsage: " ", // command does not accept arguments
|
2020-09-30 01:11:33 -04:00
|
|
|
Action: runLabelDelete,
|
2021-06-22 10:23:09 -04:00
|
|
|
Flags: append([]cli.Flag{
|
2020-09-30 01:11:33 -04:00
|
|
|
&cli.IntFlag{
|
|
|
|
Name: "id",
|
|
|
|
Usage: "label id",
|
|
|
|
},
|
2021-06-22 10:23:09 -04:00
|
|
|
}, flags.AllDefaultFlags...),
|
2020-09-30 01:11:33 -04:00
|
|
|
}
|
|
|
|
|
2020-12-15 12:38:22 -05:00
|
|
|
func runLabelDelete(cmd *cli.Context) error {
|
|
|
|
ctx := context.InitCommand(cmd)
|
|
|
|
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
2020-09-30 01:11:33 -04:00
|
|
|
|
2020-12-15 12:38:22 -05:00
|
|
|
_, err := ctx.Login.Client().DeleteLabel(ctx.Owner, ctx.Repo, ctx.Int64("id"))
|
2020-12-16 11:18:10 -05:00
|
|
|
return err
|
2020-09-30 01:11:33 -04:00
|
|
|
}
|