2018-07-18 17:41:09 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2018-09-13 13:20:28 +03:00
|
|
|
"fmt"
|
2018-08-13 19:32:11 +03:00
|
|
|
|
2018-08-31 14:18:03 +03:00
|
|
|
"github.com/MichaelMure/git-bug/cache"
|
2018-09-18 14:28:01 +03:00
|
|
|
"github.com/MichaelMure/git-bug/commands/select"
|
2018-10-25 00:36:39 +03:00
|
|
|
"github.com/MichaelMure/git-bug/util/interrupt"
|
2018-07-19 13:30:25 +03:00
|
|
|
"github.com/spf13/cobra"
|
2018-07-18 17:41:09 +03:00
|
|
|
)
|
|
|
|
|
2018-07-19 13:30:25 +03:00
|
|
|
func runLabel(cmd *cobra.Command, args []string) error {
|
2018-08-31 14:18:03 +03:00
|
|
|
backend, err := cache.NewRepoCache(repo)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer backend.Close()
|
2018-10-25 00:36:39 +03:00
|
|
|
interrupt.RegisterCleaner(backend.Close)
|
2018-08-31 14:18:03 +03:00
|
|
|
|
2018-09-18 14:28:01 +03:00
|
|
|
b, args, err := _select.ResolveBug(backend, args)
|
2018-07-18 17:41:09 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-09-17 15:32:33 +03:00
|
|
|
snap := b.Snapshot()
|
2018-09-13 13:20:28 +03:00
|
|
|
|
2018-09-17 15:32:33 +03:00
|
|
|
for _, l := range snap.Labels {
|
|
|
|
fmt.Println(l)
|
2018-07-18 17:41:09 +03:00
|
|
|
}
|
|
|
|
|
2018-09-17 15:32:33 +03:00
|
|
|
return nil
|
2018-07-18 17:41:09 +03:00
|
|
|
}
|
|
|
|
|
2018-07-19 13:30:25 +03:00
|
|
|
var labelCmd = &cobra.Command{
|
2018-10-17 21:38:10 +03:00
|
|
|
Use: "label [<id>]",
|
2019-03-23 19:59:40 +03:00
|
|
|
Short: "Display, add or remove labels to/from a bug.",
|
2018-10-17 21:38:10 +03:00
|
|
|
PreRunE: loadRepo,
|
|
|
|
RunE: runLabel,
|
2018-07-19 13:30:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2018-07-20 16:46:14 +03:00
|
|
|
RootCmd.AddCommand(labelCmd)
|
2018-07-19 13:30:25 +03:00
|
|
|
|
2018-09-10 19:16:16 +03:00
|
|
|
labelCmd.Flags().SortFlags = false
|
2018-07-18 17:41:09 +03:00
|
|
|
}
|