53 lines
1.6 KiB
Go
53 lines
1.6 KiB
Go
package playlist
|
|
|
|
import (
|
|
"github.com/eat-pray-ai/yutu/pkg/playlist"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
const (
|
|
insertShort = "Create a new playlist"
|
|
insertLong = "Create a new playlist, with the specified title, description, tags, etc"
|
|
insertCidUsage = "Channel id of the playlist"
|
|
insertOutputUsage = "json, yaml, or silent"
|
|
)
|
|
|
|
var insertCmd = &cobra.Command{
|
|
Use: "insert",
|
|
Short: insertShort,
|
|
Long: insertLong,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
p := playlist.NewPlaylist(
|
|
playlist.WithTitle(title),
|
|
playlist.WithDescription(description),
|
|
playlist.WithTags(tags),
|
|
playlist.WithLanguage(language),
|
|
playlist.WithChannelId(channelId),
|
|
playlist.WithPrivacy(privacy),
|
|
playlist.WithService(nil),
|
|
)
|
|
|
|
err := p.Insert(output, cmd.OutOrStdout())
|
|
if err != nil {
|
|
_ = cmd.Help()
|
|
cmd.PrintErrf("Error: %v\n", err)
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
playlistCmd.AddCommand(insertCmd)
|
|
|
|
insertCmd.Flags().StringVarP(&title, "title", "t", "", titleUsage)
|
|
insertCmd.Flags().StringVarP(&description, "description", "d", "", descUsage)
|
|
insertCmd.Flags().StringSliceVarP(&tags, "tags", "a", []string{}, tagsUsage)
|
|
insertCmd.Flags().StringVarP(&language, "language", "l", "", languageUsage)
|
|
insertCmd.Flags().StringVarP(&channelId, "channelId", "c", "", insertCidUsage)
|
|
insertCmd.Flags().StringVarP(&privacy, "privacy", "p", "", privacyUsage)
|
|
insertCmd.Flags().StringVarP(&output, "output", "o", "", insertOutputUsage)
|
|
|
|
_ = insertCmd.MarkFlagRequired("title")
|
|
_ = insertCmd.MarkFlagRequired("channel")
|
|
_ = insertCmd.MarkFlagRequired("privacy")
|
|
}
|