aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/label add.go7
-rw-r--r--commands/label rm.go51
2 files changed, 55 insertions, 3 deletions
diff --git a/commands/label add.go b/commands/label add.go
index c7a37be8..fccbfaa3 100644
--- a/commands/label add.go
+++ b/commands/label add.go
@@ -28,14 +28,15 @@ func runLabelAdd(cmd *cobra.Command, args []string) error {
}
changes, err := b.ChangeLabels(add, nil)
- if err != nil {
- return err
- }
for _, change := range changes {
fmt.Println(change)
}
+ if err != nil {
+ return err
+ }
+
return b.Commit()
}
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)
+}