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