git-bug/commands/label_rm.go

43 lines
748 B
Go
Raw Normal View History

package commands
import (
"github.com/spf13/cobra"
"github.com/MichaelMure/git-bug/commands/select"
)
2020-06-28 19:26:29 +03:00
func newLabelRmCommand() *cobra.Command {
env := newEnv()
cmd := &cobra.Command{
Use: "rm [<id>] <label>[...]",
Short: "Remove a label from a bug.",
PreRunE: loadBackend(env),
PostRunE: closeBackend(env),
2020-06-28 19:26:29 +03:00
RunE: func(cmd *cobra.Command, args []string) error {
return runLabelRm(env, args)
},
}
return cmd
}
func runLabelRm(env *Env, args []string) error {
b, args, err := _select.ResolveBug(env.backend, args)
if err != nil {
return err
}
2019-02-24 14:58:04 +03:00
changes, _, err := b.ChangeLabels(nil, args)
for _, change := range changes {
2020-06-28 19:26:29 +03:00
env.out.Println(change)
}
if err != nil {
return err
}
return b.Commit()
}