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