aboutsummaryrefslogtreecommitdiffstats
path: root/commands/label add.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/label add.go')
-rw-r--r--commands/label add.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/commands/label add.go b/commands/label add.go
new file mode 100644
index 00000000..6eefa646
--- /dev/null
+++ b/commands/label add.go
@@ -0,0 +1,50 @@
+package commands
+
+import (
+ "errors"
+ "fmt"
+
+ "github.com/MichaelMure/git-bug/cache"
+ "github.com/spf13/cobra"
+)
+
+func runLabelAdd(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]
+ add := args[1:]
+
+ b, err := backend.ResolveBugPrefix(prefix)
+ if err != nil {
+ return err
+ }
+
+ changes, err := b.ChangeLabels(add, nil)
+ if err != nil {
+ return err
+ }
+
+ for _, change := range changes {
+ fmt.Println(change)
+ }
+
+ return b.Commit()
+}
+
+var labelAddCmd = &cobra.Command{
+ Use: "add <id> [<label>...]",
+ Short: "Add a label to a bug",
+ RunE: runLabelAdd,
+}
+
+func init() {
+ // labelCmd.AddCommand(labelAddCmd)
+}