From 63015c6a9796728c8d90bc9ae829431f38e3412d Mon Sep 17 00:00:00 2001 From: chaoqun <27287694+OpenWaygate@users.noreply.github.com> Date: Sun, 5 May 2024 22:05:25 +0800 Subject: [PATCH] :children_crossing: Update help messages --- cmd/channel/list.go | 4 ++-- cmd/i18nLanguage/list.go | 4 ++-- cmd/i18nRegion/list.go | 4 ++-- cmd/member/list.go | 3 ++- cmd/playlist/list.go | 6 +++--- cmd/playlistItem/list.go | 2 +- cmd/video/list.go | 4 ++-- pkg/yutuber/playlistItem.go | 30 +++++++++++++++--------------- 8 files changed, 29 insertions(+), 28 deletions(-) diff --git a/cmd/channel/list.go b/cmd/channel/list.go index 9034118..ce43575 100644 --- a/cmd/channel/list.go +++ b/cmd/channel/list.go @@ -21,8 +21,8 @@ var listCmd = &cobra.Command{ func init() { channelCmd.AddCommand(listCmd) - listCmd.Flags().StringVarP(&id, "id", "i", "", "ID of the channel") - listCmd.Flags().StringVarP(&user, "user", "u", "", "User that owns the channel") + listCmd.Flags().StringVarP(&id, "id", "i", "", "Return the channels with the specified IDs") + listCmd.Flags().StringVarP(&user, "user", "u", "", "Return the channel associated with a YouTube username") listCmd.Flags().StringVarP(&output, "output", "o", "", "Output format: json or yaml") listCmd.Flags().StringArrayVarP(&parts, "parts", "p", []string{"id", "snippet", "status"}, "Comma separated parts") } diff --git a/cmd/i18nLanguage/list.go b/cmd/i18nLanguage/list.go index a8e2391..623f5a9 100644 --- a/cmd/i18nLanguage/list.go +++ b/cmd/i18nLanguage/list.go @@ -18,9 +18,9 @@ var listCmd = &cobra.Command{ func init() { i18nLanguageCmd.AddCommand(listCmd) listCmd.Flags().StringSliceVarP( - &parts, "parts", "p", []string{"id", "snippet"}, "comma separated parts", + &parts, "parts", "p", []string{"id", "snippet"}, "Comma separated parts", ) listCmd.Flags().StringVarP( - &output, "output", "o", "", "output format: json or yaml", + &output, "output", "o", "", "Output format: json or yaml", ) } diff --git a/cmd/i18nRegion/list.go b/cmd/i18nRegion/list.go index dc813de..0ef5f67 100644 --- a/cmd/i18nRegion/list.go +++ b/cmd/i18nRegion/list.go @@ -18,9 +18,9 @@ var listCmd = &cobra.Command{ func init() { i18nRegionCmd.AddCommand(listCmd) listCmd.Flags().StringSliceVarP( - &parts, "parts", "p", []string{"id", "snippet"}, "comma separated parts", + &parts, "parts", "p", []string{"id", "snippet"}, "Comma separated parts", ) listCmd.Flags().StringVarP( - &output, "output", "o", "", "output format: json or yaml", + &output, "output", "o", "", "Output format: json or yaml", ) } diff --git a/cmd/member/list.go b/cmd/member/list.go index 0efd0e2..a0e6f5e 100644 --- a/cmd/member/list.go +++ b/cmd/member/list.go @@ -21,7 +21,8 @@ func init() { memberCmd.AddCommand(listCmd) listCmd.Flags().StringVarP( - &memberChannelId, "memberChannelId", "c", "", "Comma separated channelIDs", + &memberChannelId, "memberChannelId", "c", "", + "Comma separated list of channel IDs. Only data about members that are part of this list will be included", ) listCmd.Flags().StringSliceVarP( &parts, "parts", "p", []string{"snippet"}, "Comma separated parts", diff --git a/cmd/playlist/list.go b/cmd/playlist/list.go index 60a48a4..9e8185b 100644 --- a/cmd/playlist/list.go +++ b/cmd/playlist/list.go @@ -22,8 +22,8 @@ var listCmd = &cobra.Command{ func init() { playlistCmd.AddCommand(listCmd) - listCmd.Flags().StringVarP(&id, "id", "i", "", "ID of the playlist") - listCmd.Flags().StringVarP(&channelId, "channelId", "c", "", "ID of the channel") - listCmd.Flags().StringVarP(&output, "output", "o", "", "Output format: json or yaml") + listCmd.Flags().StringVarP(&id, "id", "i", "", "Return the playlists with the given IDs for Stubby or Apiary.") + listCmd.Flags().StringVarP(&channelId, "channelId", "c", "", "Return the playlists owned by the specified channel ID") listCmd.Flags().StringArrayVarP(&parts, "parts", "p", []string{"id", "snippet", "status"}, "Comma separated parts") + listCmd.Flags().StringVarP(&output, "output", "o", "", "Output format: json or yaml") } diff --git a/cmd/playlistItem/list.go b/cmd/playlistItem/list.go index 15cd0b9..81895e1 100644 --- a/cmd/playlistItem/list.go +++ b/cmd/playlistItem/list.go @@ -22,7 +22,7 @@ func init() { playlistItemCmd.AddCommand(listCmd) listCmd.Flags().StringVarP(&id, "id", "i", "", "ID of the playlist item") - listCmd.Flags().StringVarP(&playlistId, "playlistId", "l", "", "ID of the playlist") + listCmd.Flags().StringVarP(&playlistId, "playlistId", "l", "", "Return the playlist items within the given playlist") listCmd.Flags().StringVarP(&output, "output", "o", "", "Output format: json or yaml") listCmd.Flags().StringArrayVarP(&parts, "parts", "p", []string{"id", "snippet", "status"}, "Comma separated parts") } diff --git a/cmd/video/list.go b/cmd/video/list.go index e5b5acf..1e9cc62 100644 --- a/cmd/video/list.go +++ b/cmd/video/list.go @@ -23,8 +23,8 @@ func init() { videoCmd.AddCommand(listCmd) parts := []string{"id", "snippet", "status"} - listCmd.Flags().StringVarP(&id, "id", "i", "", "ID of the video") - listCmd.Flags().StringVarP(&rating, "rating", "r", "", "My rating of the video: like or dislike") + listCmd.Flags().StringVarP(&id, "id", "i", "", "Return videos with the given ids") + listCmd.Flags().StringVarP(&rating, "rating", "r", "", "Return videos liked/disliked by the authenticated user") listCmd.Flags().StringVarP(&output, "output", "o", "", "Output format: json or yaml") listCmd.Flags().StringArrayVarP(&parts, "parts", "p", parts, "Comma separated parts") } diff --git a/pkg/yutuber/playlistItem.go b/pkg/yutuber/playlistItem.go index a48dcaf..fc8979c 100644 --- a/pkg/yutuber/playlistItem.go +++ b/pkg/yutuber/playlistItem.go @@ -46,6 +46,21 @@ func NewPlaylistItem(opts ...PlaylistItemOption) PlaylistItem { return p } +func (pi *playlistItem) get(parts []string) []*youtube.PlaylistItem { + call := service.PlaylistItems.List(parts) + if pi.id != "" { + call = call.Id(pi.id) + } else if pi.playlistId != "" { + call = call.PlaylistId(pi.playlistId) + } + response, err := call.Do() + if err != nil { + log.Fatalln(errors.Join(errGetPlaylistItem, err), pi.id) + } + + return response.Items +} + func (pi *playlistItem) List(parts []string, output string) { playlistItems := pi.get(parts) switch output { @@ -108,21 +123,6 @@ func (pi *playlistItem) Update() { utils.PrintJSON(res) } -func (pi *playlistItem) get(parts []string) []*youtube.PlaylistItem { - call := service.PlaylistItems.List(parts) - if pi.id != "" { - call = call.Id(pi.id) - } else if pi.playlistId != "" { - call = call.PlaylistId(pi.playlistId) - } - response, err := call.Do() - if err != nil { - log.Fatalln(errors.Join(errGetPlaylistItem, err), pi.id) - } - - return response.Items -} - func WithPlaylistItemId(id string) PlaylistItemOption { return func(p *playlistItem) { p.id = id