PKGBUILD/cmd/remote/rename.go

41 lines
705 B
Go

package remote
import (
"log"
"git.cryptic.systems/fh-trier/go-flucky/pkg/config"
"github.com/spf13/cobra"
)
var renameRemoteCmd = &cobra.Command{
Use: "rename",
Short: "Rename Remote Server",
Args: cobra.ExactArgs(2),
Example: "flucky remote rename origin slave",
Run: func(cmd *cobra.Command, args []string) {
// read configuration
fc, err := config.Read(cfg)
if err != nil {
log.Fatalln(err)
}
// rename remote address
err = fc.RenameRemote(args[0], args[1])
if err != nil {
log.Fatalln(err)
}
// save new configuration
err = config.Write(fc, cfg)
if err != nil {
log.Fatalln(err)
}
},
}
func init() {
remoteCmd.AddCommand(renameRemoteCmd)
}