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