bridge_rm.go

 1package commands
 2
 3import (
 4	"fmt"
 5
 6	"github.com/spf13/cobra"
 7
 8	"github.com/MichaelMure/git-bug/bridge"
 9	"github.com/MichaelMure/git-bug/cache"
10	"github.com/MichaelMure/git-bug/util/interrupt"
11)
12
13func runBridgeRm(cmd *cobra.Command, args []string) error {
14	backend, err := cache.NewRepoCache(repo)
15	if err != nil {
16		return err
17	}
18	defer backend.Close()
19	interrupt.RegisterCleaner(backend.Close)
20
21	err = bridge.RemoveBridge(backend, args[0])
22	if err != nil {
23		return err
24	}
25
26	fmt.Printf("Successfully removed bridge configuration %v\n", args[0])
27	return nil
28}
29
30var bridgeRmCmd = &cobra.Command{
31	Use:     "rm <name>",
32	Short:   "Delete a configured bridge.",
33	PreRunE: loadRepo,
34	RunE:    runBridgeRm,
35	Args:    cobra.ExactArgs(1),
36}
37
38func init() {
39	bridgeCmd.AddCommand(bridgeRmCmd)
40}