1package commands
 2
 3import (
 4	"fmt"
 5
 6	"github.com/MichaelMure/git-bug/bridge"
 7	"github.com/MichaelMure/git-bug/cache"
 8	"github.com/MichaelMure/git-bug/util/interrupt"
 9	"github.com/spf13/cobra"
10)
11
12func runBridge(cmd *cobra.Command, args []string) error {
13	backend, err := cache.NewRepoCache(repo)
14	if err != nil {
15		return err
16	}
17	defer backend.Close()
18	interrupt.RegisterCleaner(backend.Close)
19
20	configured, err := bridge.ConfiguredBridges(backend)
21	if err != nil {
22		return err
23	}
24
25	for _, c := range configured {
26		fmt.Println(c)
27	}
28
29	return nil
30}
31
32var bridgeCmd = &cobra.Command{
33	Use:     "bridge",
34	Short:   "Configure and use bridges to other bug trackers.",
35	PreRunE: loadRepo,
36	RunE:    runBridge,
37	Args:    cobra.NoArgs,
38}
39
40func init() {
41	RootCmd.AddCommand(bridgeCmd)
42}