PKGBUILD/cmd/remote/remove.go

41 lines
706 B
Go
Raw Normal View History

2018-11-19 21:36:21 +00:00
package remote
import (
"log"
2019-02-17 17:23:59 +00:00
"git.cryptic.systems/fh-trier/go-flucky/pkg/config"
2018-11-19 21:36:21 +00:00
"github.com/spf13/cobra"
)
2018-11-21 19:48:10 +00:00
var rmRemoteCmd = &cobra.Command{
Use: "rm",
Short: "Remove Remote Server",
Aliases: []string{"remove"},
2019-02-17 17:23:59 +00:00
Args: cobra.ExactArgs(1),
2019-02-22 12:08:58 +00:00
Example: "flucky remote rm origin",
2018-11-19 21:36:21 +00:00
Run: func(cmd *cobra.Command, args []string) {
2019-02-17 17:23:59 +00:00
// read configuration
fc, err := config.Read(cfg)
if err != nil {
log.Fatalln(err)
}
// add remote entry to list
err = fc.RemoveRemote(args[0])
if err != nil {
log.Fatalln(err)
}
// save new configuration
err = config.Write(fc, cfg)
if err != nil {
log.Fatalln(err)
2018-11-19 21:36:21 +00:00
}
},
}
func init() {
2018-11-21 19:48:10 +00:00
remoteCmd.AddCommand(rmRemoteCmd)
2018-11-19 21:36:21 +00:00
}