2018-09-24 16:25:57 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2019-11-03 16:00:35 +03:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2018-09-24 16:25:57 +03:00
|
|
|
"github.com/MichaelMure/git-bug/bridge"
|
|
|
|
"github.com/MichaelMure/git-bug/cache"
|
2018-10-25 00:36:39 +03:00
|
|
|
"github.com/MichaelMure/git-bug/util/interrupt"
|
2018-09-24 16:25:57 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func runBridge(cmd *cobra.Command, args []string) error {
|
|
|
|
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-09-24 16:25:57 +03:00
|
|
|
|
|
|
|
configured, err := bridge.ConfiguredBridges(backend)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, c := range configured {
|
|
|
|
fmt.Println(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var bridgeCmd = &cobra.Command{
|
2018-10-17 21:38:10 +03:00
|
|
|
Use: "bridge",
|
2019-02-24 16:46:08 +03:00
|
|
|
Short: "Configure and use bridges to other bug trackers.",
|
2018-10-17 21:38:10 +03:00
|
|
|
PreRunE: loadRepo,
|
|
|
|
RunE: runBridge,
|
|
|
|
Args: cobra.NoArgs,
|
2018-09-24 16:25:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
RootCmd.AddCommand(bridgeCmd)
|
|
|
|
}
|