2018-09-24 16:25:57 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
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"
|
|
|
|
)
|
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
func newBridgeCommand() *cobra.Command {
|
|
|
|
env := newEnv()
|
|
|
|
|
|
|
|
cmd := &cobra.Command{
|
2020-06-28 20:09:32 +03:00
|
|
|
Use: "bridge",
|
|
|
|
Short: "Configure and use bridges to other bug trackers.",
|
|
|
|
PreRunE: loadBackend(env),
|
|
|
|
PostRunE: closeBackend(env),
|
2020-06-28 19:26:29 +03:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
return runBridge(env)
|
|
|
|
},
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd.AddCommand(newBridgeAuthCommand())
|
|
|
|
cmd.AddCommand(newBridgeConfigureCommand())
|
|
|
|
cmd.AddCommand(newBridgePullCommand())
|
|
|
|
cmd.AddCommand(newBridgePushCommand())
|
|
|
|
cmd.AddCommand(newBridgeRm())
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func runBridge(env *Env) error {
|
2020-06-28 20:09:32 +03:00
|
|
|
configured, err := bridge.ConfiguredBridges(env.backend)
|
2018-09-24 16:25:57 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, c := range configured {
|
2020-06-28 19:26:29 +03:00
|
|
|
env.out.Println(c)
|
2018-09-24 16:25:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|