mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-16 10:09:28 +02:00
Various output tweaks
This commit is contained in:
parent
e9b7aabc0a
commit
49d06b7f52
3 changed files with 9 additions and 9 deletions
|
@ -49,7 +49,7 @@ type ImportResult struct {
|
|||
|
||||
func resolveBackend(config *viper.Viper) (string, Backend, error) {
|
||||
backendName := config.GetString("backend")
|
||||
fmt.Printf("requested backend %s\n", backendName)
|
||||
// fmt.Printf("requested backend %s\n", backendName)
|
||||
backendType := knownBackends[backendName]
|
||||
if backendType == nil {
|
||||
return backendName, nil, errors.New(fmt.Sprintf("Unknown backend %s", backendName))
|
||||
|
|
|
@ -39,10 +39,10 @@ func (b DumpBackend) ImportListens(listens []Listen, oldestTimestamp time.Time)
|
|||
Count: len(listens),
|
||||
LastTimestamp: oldestTimestamp,
|
||||
}
|
||||
if result.Count > 0 {
|
||||
result.LastTimestamp = listens[len(listens)-1].ListenedAt
|
||||
}
|
||||
for _, listen := range listens {
|
||||
if listen.ListenedAt.Unix() > result.LastTimestamp.Unix() {
|
||||
result.LastTimestamp = listen.ListenedAt
|
||||
}
|
||||
fmt.Printf("Listen: \"%s\" by %s\n", listen.TrackName, listen.ArtistName())
|
||||
}
|
||||
return result, nil
|
||||
|
|
|
@ -36,9 +36,9 @@ var listensCmd = &cobra.Command{
|
|||
Short: "Transfer listens between two backends",
|
||||
Long: `Transfers listens between two configured backends.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("listens called")
|
||||
sourceConfig := getConfigFromFlag(cmd, "from")
|
||||
targetConfig := getConfigFromFlag(cmd, "to")
|
||||
sourceName, sourceConfig := getConfigFromFlag(cmd, "from")
|
||||
targetName, targetConfig := getConfigFromFlag(cmd, "to")
|
||||
fmt.Printf("Transfering 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,13 +52,13 @@ var listensCmd = &cobra.Command{
|
|||
},
|
||||
}
|
||||
|
||||
func getConfigFromFlag(cmd *cobra.Command, flagName string) *viper.Viper {
|
||||
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 config
|
||||
return configName, config
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
Loading…
Add table
Reference in a new issue