diff --git a/cmd/watch_remove.go b/cmd/watch_remove.go new file mode 100644 index 0000000..0c9d3b0 --- /dev/null +++ b/cmd/watch_remove.go @@ -0,0 +1,35 @@ +package cmd + +import ( + "fmt" + + "github.com/mathismqn/godeez/internal/store" + "github.com/spf13/cobra" +) + +var watchRemoveCmd = &cobra.Command{ + Use: "remove ", + Short: "Remove a playlist from the watch list", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + id := args[0] + ok, err := store.IsWatched(id) + if err != nil { + return err + } + if !ok { + return fmt.Errorf("playlist %s is not being watched", id) + } + + if err := store.RemoveWatchedPlaylist(id); err != nil { + return fmt.Errorf("failed to remove playlist %s from watch list: %w", id, err) + } + fmt.Printf("Playlist %s removed from watch list\n", id) + + return nil + }, +} + +func init() { + watchCmd.AddCommand(watchRemoveCmd) +}