diff options
Diffstat (limited to 'commands/bridge.go')
-rw-r--r-- | commands/bridge.go | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/commands/bridge.go b/commands/bridge.go index 3c398e6b..8a2cf38b 100644 --- a/commands/bridge.go +++ b/commands/bridge.go @@ -1,8 +1,6 @@ package commands import ( - "fmt" - "github.com/spf13/cobra" "github.com/MichaelMure/git-bug/bridge" @@ -10,8 +8,30 @@ import ( "github.com/MichaelMure/git-bug/util/interrupt" ) -func runBridge(cmd *cobra.Command, args []string) error { - backend, err := cache.NewRepoCache(repo) +func newBridgeCommand() *cobra.Command { + env := newEnv() + + cmd := &cobra.Command{ + Use: "bridge", + Short: "Configure and use bridges to other bug trackers.", + PreRunE: loadRepo(env), + 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 { + backend, err := cache.NewRepoCache(env.repo) if err != nil { return err } @@ -24,20 +44,8 @@ func runBridge(cmd *cobra.Command, args []string) error { } for _, c := range configured { - fmt.Println(c) + env.out.Println(c) } return nil } - -var bridgeCmd = &cobra.Command{ - Use: "bridge", - Short: "Configure and use bridges to other bug trackers.", - PreRunE: loadRepo, - RunE: runBridge, - Args: cobra.NoArgs, -} - -func init() { - RootCmd.AddCommand(bridgeCmd) -} |