Skip to content

Commit

Permalink
🚸 Update help messages
Browse files Browse the repository at this point in the history
  • Loading branch information
OpenWaygate committed May 5, 2024
1 parent be120cc commit 63015c6
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 28 deletions.
4 changes: 2 additions & 2 deletions cmd/channel/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
4 changes: 2 additions & 2 deletions cmd/i18nLanguage/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
}
4 changes: 2 additions & 2 deletions cmd/i18nRegion/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
}
3 changes: 2 additions & 1 deletion cmd/member/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions cmd/playlist/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion cmd/playlistItem/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
4 changes: 2 additions & 2 deletions cmd/video/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
30 changes: 15 additions & 15 deletions pkg/yutuber/playlistItem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 63015c6

Please # to comment.