2018-09-24 17:24:38 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2019-06-04 01:40:32 +03:00
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2018-09-24 17:24:38 +03:00
|
|
|
"github.com/MichaelMure/git-bug/bridge"
|
|
|
|
"github.com/MichaelMure/git-bug/cache"
|
2018-10-25 00:36:39 +03:00
|
|
|
"github.com/MichaelMure/git-bug/util/interrupt"
|
2018-09-24 17:24:38 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func runBridgeRm(cmd *cobra.Command, args []string) error {
|
|
|
|
backend, err := cache.NewRepoCache(repo)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer backend.Close()
|
2018-10-25 00:36:39 +03:00
|
|
|
interrupt.RegisterCleaner(backend.Close)
|
2018-09-24 17:24:38 +03:00
|
|
|
|
2019-06-17 00:02:59 +03:00
|
|
|
err = bridge.RemoveBridge(backend, args[0])
|
2018-09-24 17:24:38 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-07-07 13:49:42 +03:00
|
|
|
fmt.Printf("Successfully removed bridge configuration %v\n", args[0])
|
2018-09-24 17:24:38 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var bridgeRmCmd = &cobra.Command{
|
2019-06-04 01:40:32 +03:00
|
|
|
Use: "rm <name>",
|
2019-02-24 16:46:08 +03:00
|
|
|
Short: "Delete a configured bridge.",
|
2018-10-17 21:38:10 +03:00
|
|
|
PreRunE: loadRepo,
|
|
|
|
RunE: runBridgeRm,
|
|
|
|
Args: cobra.ExactArgs(1),
|
2018-09-24 17:24:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
bridgeCmd.AddCommand(bridgeRmCmd)
|
|
|
|
}
|