push.go

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