From 5262dea021ed5fe815bfc7df4e99e3953b96cf0e Mon Sep 17 00:00:00 2001 From: chaoqun <27287694+OpenWaygate@users.noreply.github.com> Date: Fri, 12 Apr 2024 23:01:47 +0800 Subject: [PATCH] :sparkles: Support list members --- cmd/member/list.go | 26 ++++++++++++++++++++++++++ cmd/member/member.go | 25 +++++++++++++++++++++++++ cmd/videoCategory/list.go | 4 ++-- main.go | 1 + 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 cmd/member/list.go create mode 100644 cmd/member/member.go diff --git a/cmd/member/list.go b/cmd/member/list.go new file mode 100644 index 0000000..efd4722 --- /dev/null +++ b/cmd/member/list.go @@ -0,0 +1,26 @@ +package member + +import ( + "github.com/eat-pray-ai/yutu/pkg/yutuber" + "github.com/spf13/cobra" +) + +var listCmd = &cobra.Command{ + Use: "list", + Short: "list channel's members", + Long: "list channel's members, such as channelId, displayName, etc.", + Run: func(cmd *cobra.Command, args []string) { + m := yutuber.NewMember( + yutuber.WithMemberChannelId(memberChannelId), + ) + m.List(parts, output) + }, +} + +func init() { + memberCmd.AddCommand(listCmd) + + listCmd.Flags().StringVarP(&memberChannelId, "memberChannelId", "c", "", "Comma separated channelIDs") + listCmd.Flags().StringSliceVarP(&parts, "parts", "p", []string{"snippet"}, "Comma separated parts") + listCmd.Flags().StringVarP(&output, "output", "o", "", "Output format: json or yaml") +} diff --git a/cmd/member/member.go b/cmd/member/member.go new file mode 100644 index 0000000..aad4783 --- /dev/null +++ b/cmd/member/member.go @@ -0,0 +1,25 @@ +package member + +import ( + "github.com/eat-pray-ai/yutu/cmd" + "github.com/spf13/cobra" +) + +var ( + memberChannelId string + parts []string + output string +) + +var memberCmd = &cobra.Command{ + Use: "member", + Short: "manipulate YouTube members", + Long: "manipulate YouTube members, only list for now", + Run: func(cmd *cobra.Command, args []string) { + cmd.Help() + }, +} + +func init() { + cmd.RootCmd.AddCommand(memberCmd) +} diff --git a/cmd/videoCategory/list.go b/cmd/videoCategory/list.go index 6348c81..dd60780 100644 --- a/cmd/videoCategory/list.go +++ b/cmd/videoCategory/list.go @@ -8,7 +8,7 @@ import ( var listCmd = &cobra.Command{ Use: "list", Short: "list video categories", - Long: "list video categories's info, such as ID, title, assignable, etc.", + Long: "list video categories' info, such as ID, title, assignable, etc.", Run: func(cmd *cobra.Command, args []string) { vc := yutuber.NewVideoCategory( yutuber.WithRegionCode(regionCode), @@ -21,6 +21,6 @@ func init() { videoCategoryCmd.AddCommand(listCmd) listCmd.Flags().StringVarP(®ionCode, "regionCode", "r", "US", "region code") - listCmd.Flags().StringSliceVarP(&parts, "part", "p", []string{"id", "snippet"}, "part") + listCmd.Flags().StringSliceVarP(&parts, "parts", "p", []string{"id", "snippet"}, "Comma separated parts") listCmd.Flags().StringVarP(&output, "output", "o", "", "Output format: json or yaml") } diff --git a/main.go b/main.go index e7cfc32..2054f33 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "github.com/eat-pray-ai/yutu/cmd" _ "github.com/eat-pray-ai/yutu/cmd/activity" _ "github.com/eat-pray-ai/yutu/cmd/channel" + _ "github.com/eat-pray-ai/yutu/cmd/member" _ "github.com/eat-pray-ai/yutu/cmd/playlist" _ "github.com/eat-pray-ai/yutu/cmd/playlistItem" _ "github.com/eat-pray-ai/yutu/cmd/video"