aboutsummaryrefslogtreecommitdiffstats
path: root/commands/label rm.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/label rm.go')
-rw-r--r--commands/label rm.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/commands/label rm.go b/commands/label rm.go
new file mode 100644
index 00000000..9908094c
--- /dev/null
+++ b/commands/label rm.go
@@ -0,0 +1,51 @@
+package commands
+
+import (
+ "errors"
+ "fmt"
+
+ "github.com/MichaelMure/git-bug/cache"
+ "github.com/spf13/cobra"
+)
+
+func runLabelRm(cmd *cobra.Command, args []string) error {
+ if len(args) == 0 {
+ return errors.New("You must provide a bug id")
+ }
+
+ backend, err := cache.NewRepoCache(repo)
+ if err != nil {
+ return err
+ }
+ defer backend.Close()
+
+ prefix := args[0]
+ remove := args[1:]
+
+ b, err := backend.ResolveBugPrefix(prefix)
+ if err != nil {
+ return err
+ }
+
+ changes, err := b.ChangeLabels(nil, remove)
+
+ for _, change := range changes {
+ fmt.Println(change)
+ }
+
+ if err != nil {
+ return err
+ }
+
+ return b.Commit()
+}
+
+var labelRmCmd = &cobra.Command{
+ Use: "rm <id> [<label>...]",
+ Short: "Remove a label from a bug",
+ RunE: runLabelRm,
+}
+
+func init() {
+ labelCmd.AddCommand(labelRmCmd)
+}