2020-09-30 07:11:33 +02: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 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`,
|
|
|
|
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
|
|
|
}
|