pull.go

 1package commands
 2
 3import (
 4	"errors"
 5	"os"
 6
 7	"github.com/MichaelMure/git-bug/cache"
 8	"github.com/spf13/cobra"
 9)
10
11func runPull(cmd *cobra.Command, args []string) error {
12	if len(args) > 1 {
13		return errors.New("Only pulling from one remote at a time is supported")
14	}
15
16	remote := "origin"
17	if len(args) == 1 {
18		remote = args[0]
19	}
20
21	backend, err := cache.NewRepoCache(repo)
22	if err != nil {
23		return err
24	}
25	defer backend.Close()
26
27	return backend.Pull(remote, os.Stdout)
28}
29
30// showCmd defines the "push" subcommand.
31var pullCmd = &cobra.Command{
32	Use:   "pull [<remote>]",
33	Short: "Pull bugs update from a git remote",
34	RunE:  runPull,
35}
36
37func init() {
38	RootCmd.AddCommand(pullCmd)
39}