| 25 | } |
| 26 | |
| 27 | func runPull(env *execenv.Env, args []string) error { |
| 28 | if len(args) > 1 { |
| 29 | return errors.New("Only pulling from one remote at a time is supported") |
| 30 | } |
| 31 | |
| 32 | remote := "origin" |
| 33 | if len(args) == 1 { |
| 34 | remote = args[0] |
| 35 | } |
| 36 | |
| 37 | env.Out.Println("Fetching remote ...") |
| 38 | |
| 39 | stdout, err := env.Backend.Fetch(remote) |
| 40 | if err != nil { |
| 41 | return err |
| 42 | } |
| 43 | |
| 44 | env.Out.Println(stdout) |
| 45 | |
| 46 | env.Out.Println("Merging data ...") |
| 47 | |
| 48 | for result := range env.Backend.MergeAll(remote) { |
| 49 | if result.Err != nil { |
| 50 | env.Err.Println(result.Err) |
| 51 | } |
| 52 | |
| 53 | if result.Status != entity.MergeStatusNothing { |
| 54 | env.Out.Printf("%s: %s\n", result.Id.Human(), result) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | return nil |
| 59 | } |