1package commands
2
3import (
4 "github.com/MichaelMure/git-bug/bridge"
5 "github.com/MichaelMure/git-bug/bridge/core"
6 "github.com/MichaelMure/git-bug/cache"
7 "github.com/spf13/cobra"
8)
9
10func runBridgePull(cmd *cobra.Command, args []string) error {
11 backend, err := cache.NewRepoCache(repo)
12 if err != nil {
13 return err
14 }
15 defer backend.Close()
16
17 var b *core.Bridge
18
19 if len(args) == 0 {
20 b, err = bridge.DefaultBridge(backend)
21 } else {
22 b, err = bridge.NewBridgeFromFullName(backend, args[0])
23 }
24
25 if err != nil {
26 return err
27 }
28
29 err = b.ImportAll()
30 if err != nil {
31 return err
32 }
33
34 return nil
35}
36
37var bridgePullCmd = &cobra.Command{
38 Use: "pull [<name>]",
39 Short: "Pull updates",
40 RunE: runBridgePull,
41}
42
43func init() {
44 bridgeCmd.AddCommand(bridgePullCmd)
45}