mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-24 05:27:56 +02:00
Implemented beam loves command
This commit is contained in:
parent
238163cb05
commit
dfaf21b234
3 changed files with 105 additions and 11 deletions
|
@ -26,7 +26,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/backends"
|
||||
)
|
||||
|
||||
|
@ -38,7 +37,7 @@ var listensCmd = &cobra.Command{
|
|||
Run: func(cmd *cobra.Command, args []string) {
|
||||
sourceName, sourceConfig := getConfigFromFlag(cmd, "from")
|
||||
targetName, targetConfig := getConfigFromFlag(cmd, "to")
|
||||
fmt.Printf("Transfering listens from %s to %s...\n", sourceName, targetName)
|
||||
fmt.Printf("Transferring listens from %s to %s...\n", sourceName, targetName)
|
||||
exportBackend, err := backends.ResolveBackend[backends.ListenExport](sourceConfig)
|
||||
cobra.CheckErr(err)
|
||||
importBackend, err := backends.ResolveBackend[backends.ListenImport](targetConfig)
|
||||
|
@ -52,15 +51,6 @@ var listensCmd = &cobra.Command{
|
|||
},
|
||||
}
|
||||
|
||||
func getConfigFromFlag(cmd *cobra.Command, flagName string) (string, *viper.Viper) {
|
||||
configName := cmd.Flag(flagName).Value.String()
|
||||
config := viper.Sub(configName)
|
||||
if config == nil {
|
||||
cobra.CheckErr(fmt.Sprintf("Invalid source configuration \"%s\"", configName))
|
||||
}
|
||||
return configName, config
|
||||
}
|
||||
|
||||
func init() {
|
||||
beamCmd.AddCommand(listensCmd)
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue