diff --git a/cmd/activity/activity.go b/cmd/activity/activity.go index a0399a7..e7286cc 100644 --- a/cmd/activity/activity.go +++ b/cmd/activity/activity.go @@ -29,6 +29,7 @@ var ( regionCode string parts []string output string + jpath string ) var activityCmd = &cobra.Command{ diff --git a/cmd/activity/list.go b/cmd/activity/list.go index 2dcf04e..1fd0d9b 100644 --- a/cmd/activity/list.go +++ b/cmd/activity/list.go @@ -53,6 +53,10 @@ var listTool = mcp.NewTool( "output", mcp.DefaultString("table"), mcp.Description(cmd.TableUsage), mcp.Required(), ), + mcp.WithString( + "jsonpath", mcp.DefaultString(""), + mcp.Description(cmd.JpUsage), mcp.Required(), + ), ) func run(writer io.Writer) error { @@ -67,7 +71,7 @@ func run(writer io.Writer) error { activity.WithService(nil), ) - return a.List(parts, output, writer) + return a.List(parts, output, jpath, writer) } var listCmd = &cobra.Command{ @@ -99,6 +103,7 @@ func init() { listCmd.Flags().StringVarP(®ionCode, "regionCode", "r", "", rcUsage) listCmd.Flags().StringSliceVarP(&parts, "parts", "p", defaultParts, partsUsage) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } func listHandler(ctx context.Context, request mcp.CallToolRequest) ( @@ -124,6 +129,7 @@ func listHandler(ctx context.Context, request mcp.CallToolRequest) ( parts[i] = part.(string) } output, _ = args["output"].(string) + jpath, _ = args["jsonpath"].(string) var writer bytes.Buffer err := run(&writer) diff --git a/cmd/caption/caption.go b/cmd/caption/caption.go index d749be4..65214d2 100644 --- a/cmd/caption/caption.go +++ b/cmd/caption/caption.go @@ -42,9 +42,10 @@ var ( onBehalfOfContentOwner string videoId string parts []string - output string tfmt string tlang string + output string + jpath string ) var captionCmd = &cobra.Command{ diff --git a/cmd/caption/insert.go b/cmd/caption/insert.go index e8a7f28..c5b3d61 100644 --- a/cmd/caption/insert.go +++ b/cmd/caption/insert.go @@ -33,7 +33,7 @@ var insertCmd = &cobra.Command{ caption.WithService(nil), ) - err := c.Insert(output, cmd.OutOrStdout()) + err := c.Insert(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -68,6 +68,7 @@ func init() { &onBehalfOfContentOwner, "onBehalfOfContentOwner", "B", "", "", ) insertCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + insertCmd.Flags().StringVarP(&jpath, "jsonPath", "j", "", cmd.JpUsage) _ = insertCmd.MarkFlagRequired("file") _ = insertCmd.MarkFlagRequired("videoId") diff --git a/cmd/caption/list.go b/cmd/caption/list.go index f309885..a8aa9f1 100644 --- a/cmd/caption/list.go +++ b/cmd/caption/list.go @@ -25,7 +25,7 @@ var listCmd = &cobra.Command{ caption.WithService(nil), ) - err := c.List(parts, output, cmd.OutOrStdout()) + err := c.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -46,4 +46,5 @@ func init() { &parts, "parts", "p", []string{"id", "snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/caption/update.go b/cmd/caption/update.go index 4a8ea1b..b795001 100644 --- a/cmd/caption/update.go +++ b/cmd/caption/update.go @@ -33,7 +33,7 @@ var updateCmd = &cobra.Command{ caption.WithService(nil), ) - err := c.Update(output, cmd.OutOrStdout()) + err := c.Update(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -68,6 +68,7 @@ func init() { &onBehalfOfContentOwner, "onBehalfOfContentOwner", "B", "", "", ) updateCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + updateCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) _ = updateCmd.MarkFlagRequired("videoId") } diff --git a/cmd/channel/channel.go b/cmd/channel/channel.go index aef6a82..ea5c022 100644 --- a/cmd/channel/channel.go +++ b/cmd/channel/channel.go @@ -42,8 +42,9 @@ var ( defaultLanguage string description string title string - output string parts []string + output string + jpath string onBehalfOfContentOwner string ) diff --git a/cmd/channel/list.go b/cmd/channel/list.go index fbcee9b..105fbc9 100644 --- a/cmd/channel/list.go +++ b/cmd/channel/list.go @@ -31,7 +31,7 @@ var listCmd = &cobra.Command{ channel.WithService(nil), ) - err := c.List(parts, output, cmd.OutOrStdout()) + err := c.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -66,8 +66,9 @@ func init() { listCmd.Flags().StringVarP( &onBehalfOfContentOwner, "onBehalfOfContentOwner", "b", "", "", ) - listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) listCmd.Flags().StringSliceVarP( &parts, "parts", "p", []string{"id", "snippet", "status"}, partsUsage, ) + listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/channel/update.go b/cmd/channel/update.go index 9c87b60..9616f19 100644 --- a/cmd/channel/update.go +++ b/cmd/channel/update.go @@ -27,7 +27,7 @@ var updateCmd = &cobra.Command{ channel.WithService(nil), ) - err := c.Update(output, cmd.OutOrStdout()) + err := c.Update(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -49,6 +49,7 @@ func init() { ) updateCmd.Flags().StringVarP(&title, "title", "t", "", titleUsage) updateCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + updateCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) _ = updateCmd.MarkFlagRequired("id") } diff --git a/cmd/channelBanner/channelBanner.go b/cmd/channelBanner/channelBanner.go index 122d5ca..fe16aa3 100644 --- a/cmd/channelBanner/channelBanner.go +++ b/cmd/channelBanner/channelBanner.go @@ -16,6 +16,7 @@ var ( channelId string file string output string + jpath string onBehalfOfContentOwner string onBehalfOfContentOwnerChannel string diff --git a/cmd/channelBanner/insert.go b/cmd/channelBanner/insert.go index a4c7d3f..ab6e7ee 100644 --- a/cmd/channelBanner/insert.go +++ b/cmd/channelBanner/insert.go @@ -19,7 +19,7 @@ var insertCmd = &cobra.Command{ channelBanner.WithService(nil), ) - err := cb.Insert(output, cmd.OutOrStdout()) + err := cb.Insert(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -39,6 +39,7 @@ func init() { &onBehalfOfContentOwnerChannel, "onBehalfOfContentOwnerChannel", "B", "", "", ) insertCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + insertCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) _ = insertCmd.MarkFlagRequired("channelId") _ = insertCmd.MarkFlagRequired("file") diff --git a/cmd/channelSection/channelSection.go b/cmd/channelSection/channelSection.go index 1f2c911..ffb9de7 100644 --- a/cmd/channelSection/channelSection.go +++ b/cmd/channelSection/channelSection.go @@ -23,6 +23,7 @@ var ( onBehalfOfContentOwner string parts []string output string + jpath string ) var channelSectionCmd = &cobra.Command{ diff --git a/cmd/channelSection/list.go b/cmd/channelSection/list.go index 6587ac9..022a902 100644 --- a/cmd/channelSection/list.go +++ b/cmd/channelSection/list.go @@ -26,7 +26,7 @@ var listCmd = &cobra.Command{ channelSection.WithService(nil), ) - err := cs.List(parts, output, cmd.OutOrStdout()) + err := cs.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -48,4 +48,5 @@ func init() { &parts, "parts", "p", []string{"id", "snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/comment/comment.go b/cmd/comment/comment.go index d1c8f80..ab77432 100644 --- a/cmd/comment/comment.go +++ b/cmd/comment/comment.go @@ -38,6 +38,7 @@ var ( viewerRating string parts []string output string + jpath string ) var commentCmd = &cobra.Command{ diff --git a/cmd/comment/insert.go b/cmd/comment/insert.go index 020099e..2bad2af 100644 --- a/cmd/comment/insert.go +++ b/cmd/comment/insert.go @@ -27,7 +27,7 @@ var insertCmd = &cobra.Command{ comment.WithService(nil), ) - err := c.Insert(output, cmd.OutOrStdout()) + err := c.Insert(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -53,6 +53,7 @@ func init() { ) insertCmd.Flags().StringVarP(&videoId, "videoId", "v", "", vidUsage) insertCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + insertCmd.Flags().StringVarP(&jpath, "jsonPath", "j", "", cmd.JpUsage) _ = insertCmd.MarkFlagRequired("authorChannelId") _ = insertCmd.MarkFlagRequired("channelId") diff --git a/cmd/comment/list.go b/cmd/comment/list.go index be4781a..7b07bfb 100644 --- a/cmd/comment/list.go +++ b/cmd/comment/list.go @@ -25,7 +25,7 @@ var listCmd = &cobra.Command{ comment.WithService(nil), ) - err := c.List(parts, output, cmd.OutOrStdout()) + err := c.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -48,4 +48,5 @@ func init() { &parts, "parts", "p", []string{"id", "snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/comment/markAsSpam.go b/cmd/comment/markAsSpam.go index 1f4808f..033e64c 100644 --- a/cmd/comment/markAsSpam.go +++ b/cmd/comment/markAsSpam.go @@ -21,7 +21,7 @@ var markAsSpamCmd = &cobra.Command{ comment.WithService(nil), ) - err := c.MarkAsSpam(output, cmd.OutOrStdout()) + err := c.MarkAsSpam(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -34,6 +34,7 @@ func init() { markAsSpamCmd.Flags().StringSliceVarP(&ids, "ids", "i", []string{}, idsUsage) markAsSpamCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + markAsSpamCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) _ = markAsSpamCmd.MarkFlagRequired("ids") } diff --git a/cmd/comment/setModerationStatus.go b/cmd/comment/setModerationStatus.go index ffc40b7..a54e8d7 100644 --- a/cmd/comment/setModerationStatus.go +++ b/cmd/comment/setModerationStatus.go @@ -22,7 +22,7 @@ var setModerationStatusCmd = &cobra.Command{ comment.WithBanAuthor(banAuthor), ) - err := c.SetModerationStatus(output, cmd.OutOrStdout()) + err := c.SetModerationStatus(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -45,6 +45,9 @@ func init() { setModerationStatusCmd.Flags().StringVarP( &output, "output", "o", "", cmd.SilentUsage, ) + setModerationStatusCmd.Flags().StringVarP( + &jpath, "jsonpath", "j", "", cmd.JpUsage, + ) _ = setModerationStatusCmd.MarkFlagRequired("ids") _ = setModerationStatusCmd.MarkFlagRequired("moderationStatus") diff --git a/cmd/comment/update.go b/cmd/comment/update.go index 4574235..eaeb435 100644 --- a/cmd/comment/update.go +++ b/cmd/comment/update.go @@ -25,7 +25,7 @@ var updateCmd = &cobra.Command{ comment.WithService(nil), ) - err := c.Update(output, cmd.OutOrStdout()) + err := c.Update(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -45,6 +45,7 @@ func init() { &viewerRating, "viewerRating", "r", "", vrUsage, ) updateCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + updateCmd.Flags().StringVarP(&jpath, "jsonPath", "j", "", cmd.JpUsage) _ = updateCmd.MarkFlagRequired("id") } diff --git a/cmd/commentThread/commentThread.go b/cmd/commentThread/commentThread.go index e381c4d..24c7024 100644 --- a/cmd/commentThread/commentThread.go +++ b/cmd/commentThread/commentThread.go @@ -35,6 +35,7 @@ var ( videoId string parts []string output string + jpath string ) var commentThreadCmd = &cobra.Command{ diff --git a/cmd/commentThread/insert.go b/cmd/commentThread/insert.go index 530689c..0127168 100644 --- a/cmd/commentThread/insert.go +++ b/cmd/commentThread/insert.go @@ -25,7 +25,7 @@ var insertCmd = &cobra.Command{ commentThread.WithService(nil), ) - err := ct.Insert(output, cmd.OutOrStdout()) + err := ct.Insert(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -42,6 +42,7 @@ func init() { insertCmd.Flags().StringVarP(&textOriginal, "textOriginal", "t", "", toUsage) insertCmd.Flags().StringVarP(&videoId, "videoId", "v", "", insertVidUsage) insertCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + insertCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) _ = insertCmd.MarkFlagRequired("authorChannelId") _ = insertCmd.MarkFlagRequired("channelId") diff --git a/cmd/commentThread/list.go b/cmd/commentThread/list.go index 257d9d0..18464a8 100644 --- a/cmd/commentThread/list.go +++ b/cmd/commentThread/list.go @@ -30,7 +30,7 @@ var listCmd = &cobra.Command{ commentThread.WithService(nil), ) - err := ct.List(parts, output, cmd.OutOrStdout()) + err := ct.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -59,4 +59,5 @@ func init() { &parts, "parts", "p", []string{"id", "snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/constants.go b/cmd/constants.go index 8b74266..f4dc518 100644 --- a/cmd/constants.go +++ b/cmd/constants.go @@ -3,4 +3,5 @@ package cmd const ( TableUsage = "json, yaml, or table" SilentUsage = "json, yaml, or silent" + JpUsage = "JSONPath expression to filter the output" ) diff --git a/cmd/i18nLanguage/i18nLanguage.go b/cmd/i18nLanguage/i18nLanguage.go index b56857c..c574959 100644 --- a/cmd/i18nLanguage/i18nLanguage.go +++ b/cmd/i18nLanguage/i18nLanguage.go @@ -16,6 +16,7 @@ var ( hl string parts []string output string + jpath string ) var i18nLanguageCmd = &cobra.Command{ diff --git a/cmd/i18nLanguage/list.go b/cmd/i18nLanguage/list.go index 2c810c9..9e16d5a 100644 --- a/cmd/i18nLanguage/list.go +++ b/cmd/i18nLanguage/list.go @@ -15,7 +15,7 @@ var listCmd = &cobra.Command{ i18nLanguage.WithHl(hl), i18nLanguage.WithService(nil), ) - err := i.List(parts, output, cmd.OutOrStdout()) + err := i.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -30,4 +30,5 @@ func init() { &parts, "parts", "p", []string{"id", "snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/i18nRegion/i18nRegion.go b/cmd/i18nRegion/i18nRegion.go index b9eb320..7bd30b7 100644 --- a/cmd/i18nRegion/i18nRegion.go +++ b/cmd/i18nRegion/i18nRegion.go @@ -16,6 +16,7 @@ var ( hl string parts []string output string + jpath string ) var i18nRegionCmd = &cobra.Command{ diff --git a/cmd/i18nRegion/list.go b/cmd/i18nRegion/list.go index 38b9552..bef957b 100644 --- a/cmd/i18nRegion/list.go +++ b/cmd/i18nRegion/list.go @@ -15,7 +15,7 @@ var listCmd = &cobra.Command{ i18nRegion.WithHl(hl), i18nRegion.WithService(nil), ) - err := i.List(parts, output, cmd.OutOrStdout()) + err := i.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -30,4 +30,5 @@ func init() { &parts, "parts", "p", []string{"id", "snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/member/list.go b/cmd/member/list.go index 0dfc885..5a1f6d8 100644 --- a/cmd/member/list.go +++ b/cmd/member/list.go @@ -19,7 +19,7 @@ var listCmd = &cobra.Command{ member.WithService(nil), ) - err := m.List(parts, output, cmd.OutOrStdout()) + err := m.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -42,4 +42,5 @@ func init() { &parts, "parts", "p", []string{"snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/member/member.go b/cmd/member/member.go index 289ecf4..6ad0294 100644 --- a/cmd/member/member.go +++ b/cmd/member/member.go @@ -22,6 +22,7 @@ var ( mode string parts []string output string + jpath string ) var memberCmd = &cobra.Command{ diff --git a/cmd/membershipsLevel/list.go b/cmd/membershipsLevel/list.go index d23fd30..4246936 100644 --- a/cmd/membershipsLevel/list.go +++ b/cmd/membershipsLevel/list.go @@ -1,6 +1,7 @@ package membershipsLevel import ( + "github.com/eat-pray-ai/yutu/cmd" "github.com/eat-pray-ai/yutu/pkg/membershipsLevel" "github.com/spf13/cobra" ) @@ -12,7 +13,7 @@ var listCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { m := membershipsLevel.NewMembershipsLevel(membershipsLevel.WithService(nil)) - err := m.List(parts, output, cmd.OutOrStdout()) + err := m.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -27,4 +28,5 @@ func init() { &parts, "parts", "p", []string{"id, snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", outputUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/membershipsLevel/membershipsLevel.go b/cmd/membershipsLevel/membershipsLevel.go index 4ccbf89..a7e23ee 100644 --- a/cmd/membershipsLevel/membershipsLevel.go +++ b/cmd/membershipsLevel/membershipsLevel.go @@ -15,6 +15,7 @@ const ( var ( parts []string output string + jpath string ) var membershipsLevelCmd = &cobra.Command{ diff --git a/cmd/playlist/insert.go b/cmd/playlist/insert.go index 11905fb..9a50816 100644 --- a/cmd/playlist/insert.go +++ b/cmd/playlist/insert.go @@ -27,7 +27,7 @@ var insertCmd = &cobra.Command{ playlist.WithService(nil), ) - err := p.Insert(output, cmd.OutOrStdout()) + err := p.Insert(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -45,6 +45,7 @@ func init() { insertCmd.Flags().StringVarP(&channelId, "channelId", "c", "", insertCidUsage) insertCmd.Flags().StringVarP(&privacy, "privacy", "p", "", privacyUsage) insertCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + insertCmd.Flags().StringVarP(&jpath, "jsonPath", "j", "", cmd.JpUsage) _ = insertCmd.MarkFlagRequired("title") _ = insertCmd.MarkFlagRequired("channel") diff --git a/cmd/playlist/list.go b/cmd/playlist/list.go index b4be181..8e42db0 100644 --- a/cmd/playlist/list.go +++ b/cmd/playlist/list.go @@ -29,7 +29,7 @@ var listCmd = &cobra.Command{ playlist.WithService(nil), ) - err := p.List(parts, output, cmd.OutOrStdout()) + err := p.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -55,4 +55,5 @@ func init() { &parts, "parts", "p", []string{"id", "snippet", "status"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonPath", "j", "", cmd.JpUsage) } diff --git a/cmd/playlist/playlist.go b/cmd/playlist/playlist.go index 8d8365c..c5b5aab 100644 --- a/cmd/playlist/playlist.go +++ b/cmd/playlist/playlist.go @@ -32,8 +32,9 @@ var ( language string channelId string privacy string - output string parts []string + output string + jpath string onBehalfOfContentOwner string onBehalfOfContentOwnerChannel string diff --git a/cmd/playlist/update.go b/cmd/playlist/update.go index b6ce624..f961fd7 100644 --- a/cmd/playlist/update.go +++ b/cmd/playlist/update.go @@ -27,7 +27,7 @@ var updateCmd = &cobra.Command{ playlist.WithService(nil), ) - err := p.Update(output, cmd.OutOrStdout()) + err := p.Update(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -45,6 +45,7 @@ func init() { updateCmd.Flags().StringVarP(&language, "language", "l", "", languageUsage) updateCmd.Flags().StringVarP(&privacy, "privacy", "p", "", privacyUsage) updateCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + updateCmd.Flags().StringVarP(&jpath, "jsonPath", "j", "", cmd.JpUsage) _ = updateCmd.MarkFlagRequired("id") } diff --git a/cmd/playlistImage/insert.go b/cmd/playlistImage/insert.go index 7c9a474..9c61c5a 100644 --- a/cmd/playlistImage/insert.go +++ b/cmd/playlistImage/insert.go @@ -25,7 +25,7 @@ var insertCmd = &cobra.Command{ playlistImage.WithService(nil), ) - err := pi.Insert(output, cmd.OutOrStdout()) + err := pi.Insert(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -42,6 +42,7 @@ func init() { insertCmd.Flags().Int64VarP(&height, "height", "H", 0, heightUsage) insertCmd.Flags().Int64VarP(&width, "width", "W", 0, widthUsage) insertCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + insertCmd.Flags().StringVarP(&jpath, "jsonPath", "j", "", cmd.JpUsage) _ = insertCmd.MarkFlagRequired("file") _ = insertCmd.MarkFlagRequired("playlistId") diff --git a/cmd/playlistImage/list.go b/cmd/playlistImage/list.go index b396d8d..712e70f 100644 --- a/cmd/playlistImage/list.go +++ b/cmd/playlistImage/list.go @@ -24,7 +24,7 @@ var listCmd = &cobra.Command{ playlistImage.WithService(nil), ) - err := pi.List(parts, output, cmd.OutOrStdout()) + err := pi.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -41,6 +41,7 @@ func init() { &parts, "parts", "p", []string{"id", "kind", "snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonPath", "j", "", cmd.JpUsage) listCmd.Flags().StringVarP( &onBehalfOfContentOwner, "onBehalfOfContentOwner", "b", "", "", ) diff --git a/cmd/playlistImage/playlistImage.go b/cmd/playlistImage/playlistImage.go index 91e43de..92a721a 100644 --- a/cmd/playlistImage/playlistImage.go +++ b/cmd/playlistImage/playlistImage.go @@ -30,6 +30,7 @@ var ( maxResults int64 parts []string output string + jpath string onBehalfOfContentOwner string onBehalfOfContentOwnerChannel string diff --git a/cmd/playlistImage/update.go b/cmd/playlistImage/update.go index 14faa9d..bcd2e23 100644 --- a/cmd/playlistImage/update.go +++ b/cmd/playlistImage/update.go @@ -24,7 +24,7 @@ var updateCmd = &cobra.Command{ playlistImage.WithService(nil), ) - err := pi.Update(output, cmd.OutOrStdout()) + err := pi.Update(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -40,6 +40,7 @@ func init() { updateCmd.Flags().Int64VarP(&height, "height", "H", 0, heightUsage) updateCmd.Flags().Int64VarP(&width, "width", "W", 0, widthUsage) updateCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + updateCmd.Flags().StringVarP(&jpath, "jsonPath", "j", "", cmd.JpUsage) _ = updateCmd.MarkFlagRequired("playlistId") } diff --git a/cmd/playlistItem/insert.go b/cmd/playlistItem/insert.go index 2414d76..40210d6 100644 --- a/cmd/playlistItem/insert.go +++ b/cmd/playlistItem/insert.go @@ -31,7 +31,7 @@ var insertCmd = &cobra.Command{ playlistItem.WithService(nil), ) - err := pi.Insert(output, cmd.OutOrStdout()) + err := pi.Insert(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -57,6 +57,7 @@ func init() { &onBehalfOfContentOwner, "onBehalfOfContentOwner", "b", "", "", ) insertCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + insertCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) _ = insertCmd.MarkFlagRequired("kind") _ = insertCmd.MarkFlagRequired("playlistId") diff --git a/cmd/playlistItem/list.go b/cmd/playlistItem/list.go index a4d957e..b35336c 100644 --- a/cmd/playlistItem/list.go +++ b/cmd/playlistItem/list.go @@ -27,7 +27,7 @@ var listCmd = &cobra.Command{ playlistItem.WithService(nil), ) - err := pi.List(parts, output, cmd.OutOrStdout()) + err := pi.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -45,8 +45,9 @@ func init() { listCmd.Flags().StringVarP( &onBehalfOfContentOwner, "onBehalfOfContentOwner", "b", "", "", ) - listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) listCmd.Flags().StringSliceVarP( &parts, "parts", "p", []string{"id", "snippet", "status"}, partsUsage, ) + listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/playlistItem/playlistItem.go b/cmd/playlistItem/playlistItem.go index 963ac6b..18f0e17 100644 --- a/cmd/playlistItem/playlistItem.go +++ b/cmd/playlistItem/playlistItem.go @@ -34,8 +34,9 @@ var ( channelId string maxResults int64 privacy string - output string parts []string + output string + jpath string onBehalfOfContentOwner string ) diff --git a/cmd/playlistItem/update.go b/cmd/playlistItem/update.go index 8f67075..16f2c4f 100644 --- a/cmd/playlistItem/update.go +++ b/cmd/playlistItem/update.go @@ -26,7 +26,7 @@ var updateCmd = &cobra.Command{ playlistItem.WithService(nil), ) - err := pi.Update(output, cmd.OutOrStdout()) + err := pi.Update(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -45,6 +45,7 @@ func init() { &onBehalfOfContentOwner, "onBehalfOfContentOwner", "b", "", "", ) updateCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + updateCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) _ = updateCmd.MarkFlagRequired("id") } diff --git a/cmd/search/list.go b/cmd/search/list.go index 54f6f95..f7af76d 100644 --- a/cmd/search/list.go +++ b/cmd/search/list.go @@ -44,7 +44,7 @@ var listCmd = &cobra.Command{ search.WithService(nil), ) - err := s.List(parts, output, cmd.OutOrStdout()) + err := s.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -96,4 +96,5 @@ func init() { &parts, "parts", []string{"id", "snippet"}, partsUsage, ) listCmd.Flags().StringVar(&output, "output", "table", cmd.TableUsage) + listCmd.Flags().StringVar(&jpath, "jsonpath", "", cmd.JpUsage) } diff --git a/cmd/search/search.go b/cmd/search/search.go index 25e30f9..0ad1808 100644 --- a/cmd/search/search.go +++ b/cmd/search/search.go @@ -72,6 +72,7 @@ var ( videoType string parts []string output string + jpath string ) var searchCmd = &cobra.Command{ diff --git a/cmd/subscription/insert.go b/cmd/subscription/insert.go index 478d1c0..429c5e7 100644 --- a/cmd/subscription/insert.go +++ b/cmd/subscription/insert.go @@ -25,7 +25,7 @@ var insertCmd = &cobra.Command{ subscription.WithService(nil), ) - err := s.Insert(output, cmd.OutOrStdout()) + err := s.Insert(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -43,6 +43,7 @@ func init() { insertCmd.Flags().StringVarP(&channelId, "channelId", "c", "", insertCidUsage) insertCmd.Flags().StringVarP(&title, "title", "t", "", titleUsage) insertCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + insertCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) _ = insertCmd.MarkFlagRequired("subscriberChannelId") _ = insertCmd.MarkFlagRequired("channelId") diff --git a/cmd/subscription/list.go b/cmd/subscription/list.go index a1fd462..5d4293c 100644 --- a/cmd/subscription/list.go +++ b/cmd/subscription/list.go @@ -32,7 +32,7 @@ var listCmd = &cobra.Command{ subscription.WithService(nil), ) - err := s.List(parts, output, cmd.OutOrStdout()) + err := s.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -59,8 +59,9 @@ func init() { &onBehalfOfContentOwnerChannel, "onBehalfOfContentOwnerChannel", "B", "", "", ) listCmd.Flags().StringVarP(&order, "order", "O", "relevance", orderUsage) - listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) listCmd.Flags().StringSliceVarP( &parts, "parts", "p", []string{"id", "snippet"}, partsUsage, ) + listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/subscription/subscription.go b/cmd/subscription/subscription.go index 6a67e5a..1adf252 100644 --- a/cmd/subscription/subscription.go +++ b/cmd/subscription/subscription.go @@ -37,6 +37,7 @@ var ( title string parts []string output string + jpath string ) var subscriptionCmd = &cobra.Command{ diff --git a/cmd/superChatEvent/list.go b/cmd/superChatEvent/list.go index 59ef03e..2c6217e 100644 --- a/cmd/superChatEvent/list.go +++ b/cmd/superChatEvent/list.go @@ -17,7 +17,7 @@ var listCmd = &cobra.Command{ superChatEvent.WithService(nil), ) - err := sc.List(parts, output, cmd.OutOrStdout()) + err := sc.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -34,4 +34,5 @@ func init() { &parts, "parts", "p", []string{"id", "snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/superChatEvent/superChatEvent.go b/cmd/superChatEvent/superChatEvent.go index 9114ac7..801e5f3 100644 --- a/cmd/superChatEvent/superChatEvent.go +++ b/cmd/superChatEvent/superChatEvent.go @@ -18,6 +18,7 @@ var ( maxResults int64 parts []string output string + jpath string ) var superChatEventCmd = &cobra.Command{ diff --git a/cmd/thumbnail/set.go b/cmd/thumbnail/set.go index 580cd9d..e20bca4 100644 --- a/cmd/thumbnail/set.go +++ b/cmd/thumbnail/set.go @@ -17,7 +17,7 @@ var setCmd = &cobra.Command{ thumbnail.WithService(nil), ) - err := t.Set(output, cmd.OutOrStdout()) + err := t.Set(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -31,6 +31,7 @@ func init() { setCmd.Flags().StringVarP(&file, "file", "f", "", fileUsage) setCmd.Flags().StringVarP(&videoId, "videoId", "v", "", vidUsage) setCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + setCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) _ = setCmd.MarkFlagRequired("file") _ = setCmd.MarkFlagRequired("videoId") diff --git a/cmd/thumbnail/thumbnail.go b/cmd/thumbnail/thumbnail.go index 7d93cf2..fd87f97 100644 --- a/cmd/thumbnail/thumbnail.go +++ b/cmd/thumbnail/thumbnail.go @@ -16,6 +16,7 @@ var ( file string videoId string output string + jpath string ) var thumbnailCmd = &cobra.Command{ diff --git a/cmd/video/getRating.go b/cmd/video/getRating.go index eca8561..c0b3bf5 100644 --- a/cmd/video/getRating.go +++ b/cmd/video/getRating.go @@ -1,6 +1,7 @@ package video import ( + "github.com/eat-pray-ai/yutu/cmd" "github.com/eat-pray-ai/yutu/pkg/video" "github.com/spf13/cobra" ) @@ -23,7 +24,7 @@ var getRatingCmd = &cobra.Command{ video.WithService(nil), ) - err := v.GetRating(output, cmd.OutOrStdout()) + err := v.GetRating(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -39,6 +40,7 @@ func init() { &onBehalfOfContentOwner, "onBehalfOfContentOwner", "b", "", "", ) getRatingCmd.Flags().StringVarP(&output, "output", "o", "", grOutputUsage) + getRatingCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) _ = getRatingCmd.MarkFlagRequired("ids") } diff --git a/cmd/video/insert.go b/cmd/video/insert.go index 093f553..d161cfa 100644 --- a/cmd/video/insert.go +++ b/cmd/video/insert.go @@ -41,7 +41,7 @@ var insertCmd = &cobra.Command{ video.WithService(nil), ) - err := v.Insert(output, cmd.OutOrStdout()) + err := v.Insert(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -85,6 +85,7 @@ func init() { &onBehalfOfContentOwnerChannel, "onBehalfOfContentOwnerChannel", "B", "", "", ) insertCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + insertCmd.Flags().StringVarP(&jpath, "jsonPath", "j", "", cmd.JpUsage) _ = insertCmd.MarkFlagRequired("file") _ = insertCmd.MarkFlagRequired("categoryId") diff --git a/cmd/video/list.go b/cmd/video/list.go index 249ee9a..206e406 100644 --- a/cmd/video/list.go +++ b/cmd/video/list.go @@ -33,7 +33,7 @@ var listCmd = &cobra.Command{ video.WithService(nil), ) - err := v.List(parts, output, cmd.OutOrStdout()) + err := v.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -57,8 +57,9 @@ func init() { &onBehalfOfContentOwner, "onBehalfOfContentOwner", "b", "", "", ) listCmd.Flags().StringVarP(&rating, "myRating", "R", "", listMrUsage) - listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) listCmd.Flags().StringSliceVarP( &parts, "parts", "p", []string{"id", "snippet", "status"}, partsUsage, ) + listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/video/update.go b/cmd/video/update.go index cca866b..749dcc6 100644 --- a/cmd/video/update.go +++ b/cmd/video/update.go @@ -33,7 +33,7 @@ var updateCmd = &cobra.Command{ video.WithService(nil), ) - err := v.Update(output, cmd.OutOrStdout()) + err := v.Update(output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -58,6 +58,7 @@ func init() { embeddable, "embeddable", "E", true, embeddableUsage, ) updateCmd.Flags().StringVarP(&output, "output", "o", "", cmd.SilentUsage) + updateCmd.Flags().StringVarP(&jpath, "jsonPath", "j", "", cmd.JpUsage) _ = updateCmd.MarkFlagRequired("ids") } diff --git a/cmd/video/video.go b/cmd/video/video.go index 23f7a38..539da80 100644 --- a/cmd/video/video.go +++ b/cmd/video/video.go @@ -62,8 +62,6 @@ var ( privacy string forKids = utils.BoolPtr("false") embeddable = utils.BoolPtr("false") - output string - parts []string publishAt string regionCode string reasonId string @@ -72,6 +70,9 @@ var ( maxHeight int64 maxWidth int64 maxResults int64 + parts []string + output string + jpath string notifySubscribers = utils.BoolPtr("false") publicStatsViewable = utils.BoolPtr("false") diff --git a/cmd/videoAbuseReportReason/list.go b/cmd/videoAbuseReportReason/list.go index 1144f1a..02c8988 100644 --- a/cmd/videoAbuseReportReason/list.go +++ b/cmd/videoAbuseReportReason/list.go @@ -16,7 +16,7 @@ var listCmd = &cobra.Command{ videoAbuseReportReason.WithService(nil), ) - err := va.List(parts, output, cmd.OutOrStdout()) + err := va.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -32,4 +32,5 @@ func init() { &parts, "parts", "p", []string{"id", "snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/videoAbuseReportReason/videoAbuseReportReason.go b/cmd/videoAbuseReportReason/videoAbuseReportReason.go index d24dbcd..90ecc58 100644 --- a/cmd/videoAbuseReportReason/videoAbuseReportReason.go +++ b/cmd/videoAbuseReportReason/videoAbuseReportReason.go @@ -16,6 +16,7 @@ var ( hl string parts []string output string + jpath string ) var videoAbuseReportReasonCmd = &cobra.Command{ diff --git a/cmd/videoCategory/list.go b/cmd/videoCategory/list.go index f78f07a..e446862 100644 --- a/cmd/videoCategory/list.go +++ b/cmd/videoCategory/list.go @@ -18,7 +18,7 @@ var listCmd = &cobra.Command{ videoCategory.WithService(nil), ) - err := vc.List(parts, output, cmd.OutOrStdout()) + err := vc.List(parts, output, jpath, cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) @@ -36,4 +36,5 @@ func init() { &parts, "parts", "p", []string{"id", "snippet"}, partsUsage, ) listCmd.Flags().StringVarP(&output, "output", "o", "table", cmd.TableUsage) + listCmd.Flags().StringVarP(&jpath, "jsonpath", "j", "", cmd.JpUsage) } diff --git a/cmd/videoCategory/videoCategory.go b/cmd/videoCategory/videoCategory.go index 40427b1..fcbaa66 100644 --- a/cmd/videoCategory/videoCategory.go +++ b/cmd/videoCategory/videoCategory.go @@ -20,6 +20,7 @@ var ( regionCode string parts []string output string + jpath string ) var videoCategoryCmd = &cobra.Command{ diff --git a/cmd/watermark/set.go b/cmd/watermark/set.go index 439dff1..e66b2cd 100644 --- a/cmd/watermark/set.go +++ b/cmd/watermark/set.go @@ -26,7 +26,7 @@ var setCmd = &cobra.Command{ watermark.WithService(nil), ) - err := w.Set(cmd.OutOrStdout()) + err := w.Set("", cmd.OutOrStdout()) if err != nil { _ = cmd.Help() cmd.PrintErrf("Error: %v\n", err) diff --git a/pkg/activity/activity.go b/pkg/activity/activity.go index 274cdb9..f9fa56f 100644 --- a/pkg/activity/activity.go +++ b/pkg/activity/activity.go @@ -25,7 +25,7 @@ type activity struct { } type Activity interface { - List([]string, string, io.Writer) error + List([]string, string, string, io.Writer) error Get([]string) ([]*youtube.Activity, error) } @@ -81,7 +81,7 @@ func (a *activity) Get(parts []string) ([]*youtube.Activity, error) { } func (a *activity) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { activities, err := a.Get(parts) if err != nil { @@ -90,9 +90,9 @@ func (a *activity) List( switch output { case "json": - utils.PrintJSON(activities, writer) + utils.PrintJSON(activities, jpath, writer) case "yaml": - utils.PrintYAML(activities, writer) + utils.PrintYAML(activities, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() diff --git a/pkg/caption/caption.go b/pkg/caption/caption.go index 4dce26a..4af42d5 100644 --- a/pkg/caption/caption.go +++ b/pkg/caption/caption.go @@ -41,9 +41,9 @@ type caption struct { type Caption interface { Get(parts []string) ([]*youtube.Caption, error) // todo: return error - List(parts []string, output string, writer io.Writer) error - Insert(output string, writer io.Writer) error - Update(output string, writer io.Writer) error + List(parts []string, output string, s string, writer io.Writer) error + Insert(output string, s string, writer io.Writer) error + Update(output string, s string, writer io.Writer) error Delete(writer io.Writer) error Download(writer io.Writer) error } @@ -78,7 +78,9 @@ func (c *caption) Get(parts []string) ([]*youtube.Caption, error) { return res.Items, nil } -func (c *caption) List(parts []string, output string, writer io.Writer) error { +func (c *caption) List( + parts []string, output string, jpath string, writer io.Writer, +) error { captions, err := c.Get(parts) if err != nil { return err @@ -86,9 +88,9 @@ func (c *caption) List(parts []string, output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(captions, writer) + utils.PrintJSON(captions, jpath, writer) case "yaml": - utils.PrintYAML(captions, writer) + utils.PrintYAML(captions, jpath, writer) case "table": tb := table.NewWriter() tb.SetOutputMirror(writer) @@ -108,7 +110,7 @@ func (c *caption) List(parts []string, output string, writer io.Writer) error { return nil } -func (c *caption) Insert(output string, writer io.Writer) error { +func (c *caption) Insert(output string, jpath string, writer io.Writer) error { file, err := os.Open(c.File) if err != nil { return errors.Join(errInsertCaption, err) @@ -145,9 +147,9 @@ func (c *caption) Insert(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Caption inserted: %s\n", res.Id) @@ -155,7 +157,7 @@ func (c *caption) Insert(output string, writer io.Writer) error { return nil } -func (c *caption) Update(output string, writer io.Writer) error { +func (c *caption) Update(output string, jpath string, writer io.Writer) error { captions, err := c.Get([]string{"snippet"}) if err != nil { return errors.Join(errUpdateCaption, err) @@ -219,9 +221,9 @@ func (c *caption) Update(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Caption updated: %s\n", res.Id) diff --git a/pkg/channel/channel.go b/pkg/channel/channel.go index cd37837..9f89ce8 100644 --- a/pkg/channel/channel.go +++ b/pkg/channel/channel.go @@ -37,8 +37,8 @@ type channel struct { } type Channel interface { - List([]string, string, io.Writer) error - Update(string, io.Writer) error + List([]string, string, string, io.Writer) error + Update(string, string, io.Writer) error Get([]string) ([]*youtube.Channel, error) } @@ -105,7 +105,9 @@ func (c *channel) Get(parts []string) ([]*youtube.Channel, error) { return res.Items, nil } -func (c *channel) List(parts []string, output string, writer io.Writer) error { +func (c *channel) List( + parts []string, output string, jpath string, writer io.Writer, +) error { channels, err := c.Get(parts) if err != nil { return err @@ -113,9 +115,9 @@ func (c *channel) List(parts []string, output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(channels, writer) + utils.PrintJSON(channels, jpath, writer) case "yaml": - utils.PrintYAML(channels, writer) + utils.PrintYAML(channels, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() @@ -132,7 +134,7 @@ func (c *channel) List(parts []string, output string, writer io.Writer) error { return nil } -func (c *channel) Update(output string, writer io.Writer) error { +func (c *channel) Update(output string, jpath string, writer io.Writer) error { parts := []string{"snippet"} channels, err := c.Get(parts) if err != nil { @@ -167,9 +169,9 @@ func (c *channel) Update(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Channel updated: %s\n", res.Id) diff --git a/pkg/channelBanner/channelBanner.go b/pkg/channelBanner/channelBanner.go index 6a1ece2..1766b60 100644 --- a/pkg/channelBanner/channelBanner.go +++ b/pkg/channelBanner/channelBanner.go @@ -24,7 +24,7 @@ type channelBanner struct { } type ChannelBanner interface { - Insert(string, io.Writer) error + Insert(string, string, io.Writer) error } type Option func(banner *channelBanner) @@ -39,7 +39,9 @@ func NewChannelBanner(opts ...Option) ChannelBanner { return cb } -func (cb *channelBanner) Insert(output string, writer io.Writer) error { +func (cb *channelBanner) Insert( + output string, jpath string, writer io.Writer, +) error { file, err := os.Open(cb.File) if err != nil { return errors.Join(errInsertChannelBanner, err) @@ -62,9 +64,9 @@ func (cb *channelBanner) Insert(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "ChannelBanner inserted: %s\n", res.Url) diff --git a/pkg/channelSection/channelSection.go b/pkg/channelSection/channelSection.go index 3731315..cf4c80c 100644 --- a/pkg/channelSection/channelSection.go +++ b/pkg/channelSection/channelSection.go @@ -26,7 +26,7 @@ type channelSection struct { type ChannelSection interface { Get([]string) ([]*youtube.ChannelSection, error) - List([]string, string, io.Writer) error + List([]string, string, string, io.Writer) error Delete(writer io.Writer) error // Update() // Insert() @@ -71,7 +71,7 @@ func (cs *channelSection) Get(parts []string) ( } func (cs *channelSection) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { channelSections, err := cs.Get(parts) if err != nil { @@ -80,9 +80,9 @@ func (cs *channelSection) List( switch output { case "json": - utils.PrintJSON(channelSections, writer) + utils.PrintJSON(channelSections, jpath, writer) case "yaml": - utils.PrintYAML(channelSections, writer) + utils.PrintYAML(channelSections, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() diff --git a/pkg/comment/comment.go b/pkg/comment/comment.go index d5ea3b1..3c9348d 100644 --- a/pkg/comment/comment.go +++ b/pkg/comment/comment.go @@ -37,12 +37,12 @@ type comment struct { type Comment interface { Get([]string) ([]*youtube.Comment, error) - List([]string, string, io.Writer) error - Insert(string, io.Writer) error - Update(string, io.Writer) error + List([]string, string, string, io.Writer) error + Insert(string, string, io.Writer) error + Update(string, string, io.Writer) error Delete(io.Writer) error - MarkAsSpam(string, io.Writer) error - SetModerationStatus(string, io.Writer) error + MarkAsSpam(string, string, io.Writer) error + SetModerationStatus(string, string, io.Writer) error } type Option func(*comment) @@ -85,7 +85,9 @@ func (c *comment) Get(parts []string) ([]*youtube.Comment, error) { return res.Items, nil } -func (c *comment) List(parts []string, output string, writer io.Writer) error { +func (c *comment) List( + parts []string, output string, jpath string, writer io.Writer, +) error { comments, err := c.Get(parts) if err != nil { return err @@ -93,9 +95,9 @@ func (c *comment) List(parts []string, output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(comments, writer) + utils.PrintJSON(comments, jpath, writer) case "yaml": - utils.PrintYAML(comments, writer) + utils.PrintYAML(comments, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() @@ -115,7 +117,7 @@ func (c *comment) List(parts []string, output string, writer io.Writer) error { return nil } -func (c *comment) Insert(output string, writer io.Writer) error { +func (c *comment) Insert(output string, jpath string, writer io.Writer) error { comment := &youtube.Comment{ Snippet: &youtube.CommentSnippet{ AuthorChannelId: &youtube.CommentSnippetAuthorChannelId{ @@ -140,9 +142,9 @@ func (c *comment) Insert(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Comment inserted: %s\n", res.Id) @@ -150,7 +152,7 @@ func (c *comment) Insert(output string, writer io.Writer) error { return nil } -func (c *comment) Update(output string, writer io.Writer) error { +func (c *comment) Update(output string, jpath string, writer io.Writer) error { comments, err := c.Get([]string{"id", "snippet"}) if err != nil { return errors.Join(errUpdateComment, err) @@ -180,9 +182,9 @@ func (c *comment) Update(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Comment updated: %s\n", res.Id) @@ -190,7 +192,9 @@ func (c *comment) Update(output string, writer io.Writer) error { return nil } -func (c *comment) MarkAsSpam(output string, writer io.Writer) error { +func (c *comment) MarkAsSpam( + output string, jpath string, writer io.Writer, +) error { call := service.Comments.MarkAsSpam(c.IDs) err := call.Do() if err != nil { @@ -199,9 +203,9 @@ func (c *comment) MarkAsSpam(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(c, writer) + utils.PrintJSON(c, jpath, writer) case "yaml": - utils.PrintYAML(c, writer) + utils.PrintYAML(c, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Comment marked as spam: %s\n", c.IDs) @@ -209,7 +213,9 @@ func (c *comment) MarkAsSpam(output string, writer io.Writer) error { return nil } -func (c *comment) SetModerationStatus(output string, writer io.Writer) error { +func (c *comment) SetModerationStatus( + output string, jpath string, writer io.Writer, +) error { call := service.Comments.SetModerationStatus(c.IDs, c.ModerationStatus) if c.BanAuthor != nil { @@ -223,9 +229,9 @@ func (c *comment) SetModerationStatus(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(c, writer) + utils.PrintJSON(c, jpath, writer) case "yaml": - utils.PrintYAML(c, writer) + utils.PrintYAML(c, jpath, writer) case "silent": default: _, _ = fmt.Fprintf( diff --git a/pkg/commentThread/commentThread.go b/pkg/commentThread/commentThread.go index 037944c..a4ba31b 100644 --- a/pkg/commentThread/commentThread.go +++ b/pkg/commentThread/commentThread.go @@ -32,8 +32,8 @@ type commentThread struct { type CommentThread interface { Get([]string) ([]*youtube.CommentThread, error) - List([]string, string, io.Writer) error - Insert(output string, writer io.Writer) error + List([]string, string, string, io.Writer) error + Insert(output string, s string, writer io.Writer) error } type Option func(*commentThread) @@ -97,7 +97,7 @@ func (c *commentThread) Get(parts []string) ([]*youtube.CommentThread, error) { } func (c *commentThread) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { commentThreads, err := c.Get(parts) if err != nil { @@ -106,9 +106,9 @@ func (c *commentThread) List( switch output { case "json": - utils.PrintJSON(commentThreads, writer) + utils.PrintJSON(commentThreads, jpath, writer) case "yaml": - utils.PrintYAML(commentThreads, writer) + utils.PrintYAML(commentThreads, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() @@ -129,7 +129,9 @@ func (c *commentThread) List( return nil } -func (c *commentThread) Insert(output string, writer io.Writer) error { +func (c *commentThread) Insert( + output string, jpath string, writer io.Writer, +) error { ct := &youtube.CommentThread{ Snippet: &youtube.CommentThreadSnippet{ ChannelId: c.ChannelId, @@ -153,9 +155,9 @@ func (c *commentThread) Insert(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "CommentThread inserted: %s\n", res.Id) diff --git a/pkg/i18nLanguage/i18nLanguage.go b/pkg/i18nLanguage/i18nLanguage.go index f563656..dc8d95d 100644 --- a/pkg/i18nLanguage/i18nLanguage.go +++ b/pkg/i18nLanguage/i18nLanguage.go @@ -20,7 +20,7 @@ type i18nLanguage struct { type I18nLanguage interface { Get([]string) ([]*youtube.I18nLanguage, error) - List([]string, string, io.Writer) error + List([]string, string, string, io.Writer) error } type Option func(*i18nLanguage) @@ -50,7 +50,7 @@ func (i *i18nLanguage) Get(parts []string) ([]*youtube.I18nLanguage, error) { } func (i *i18nLanguage) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { i18nLanguages, err := i.Get(parts) if err != nil { @@ -59,9 +59,9 @@ func (i *i18nLanguage) List( switch output { case "json": - utils.PrintJSON(i18nLanguages, writer) + utils.PrintJSON(i18nLanguages, jpath, writer) case "yaml": - utils.PrintYAML(i18nLanguages, writer) + utils.PrintYAML(i18nLanguages, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() diff --git a/pkg/i18nRegion/i18nRegion.go b/pkg/i18nRegion/i18nRegion.go index b54b0e6..5792ce6 100644 --- a/pkg/i18nRegion/i18nRegion.go +++ b/pkg/i18nRegion/i18nRegion.go @@ -20,7 +20,7 @@ type i18nRegion struct { type I18nRegion interface { Get([]string) ([]*youtube.I18nRegion, error) - List([]string, string, io.Writer) error + List([]string, string, string, io.Writer) error } type Option func(*i18nRegion) @@ -50,7 +50,7 @@ func (i *i18nRegion) Get(parts []string) ([]*youtube.I18nRegion, error) { } func (i *i18nRegion) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { i18nRegions, err := i.Get(parts) if err != nil { @@ -59,9 +59,9 @@ func (i *i18nRegion) List( switch output { case "json": - utils.PrintJSON(i18nRegions, writer) + utils.PrintJSON(i18nRegions, jpath, writer) case "yaml": - utils.PrintYAML(i18nRegions, writer) + utils.PrintYAML(i18nRegions, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() diff --git a/pkg/interface.go b/pkg/interface.go index bc8fb29..05f5fe8 100644 --- a/pkg/interface.go +++ b/pkg/interface.go @@ -5,11 +5,11 @@ import ( ) type Lister interface { - List([]string, string, io.Writer) error + List([]string, string, string, io.Writer) error } type Inserter interface { - Insert(string, io.Writer) error + Insert(string, string, io.Writer) error } type Deleter interface { @@ -17,13 +17,13 @@ type Deleter interface { } type Updater interface { - Update(string, io.Writer) error + Update(string, string, io.Writer) error } type Setter interface { - Set(writer io.Writer) error + Set(string, io.Writer) error } type Unsetter interface { - Unset(writer io.Writer) error + Unset(io.Writer) error } diff --git a/pkg/member/member.go b/pkg/member/member.go index 5b713b5..4ef2fdb 100644 --- a/pkg/member/member.go +++ b/pkg/member/member.go @@ -22,7 +22,7 @@ type member struct { } type Member interface { - List([]string, string, io.Writer) error + List([]string, string, string, io.Writer) error Get([]string) ([]*youtube.Member, error) } @@ -62,7 +62,9 @@ func (m *member) Get(parts []string) ([]*youtube.Member, error) { return res.Items, nil } -func (m *member) List(parts []string, output string, writer io.Writer) error { +func (m *member) List( + parts []string, output string, jpath string, writer io.Writer, +) error { members, err := m.Get(parts) if err != nil { return err @@ -70,9 +72,9 @@ func (m *member) List(parts []string, output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(members, writer) + utils.PrintJSON(members, jpath, writer) case "yaml": - utils.PrintYAML(members, writer) + utils.PrintYAML(members, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() diff --git a/pkg/membershipsLevel/membershipsLevel.go b/pkg/membershipsLevel/membershipsLevel.go index e329c53..a65d51f 100644 --- a/pkg/membershipsLevel/membershipsLevel.go +++ b/pkg/membershipsLevel/membershipsLevel.go @@ -17,7 +17,7 @@ var ( type membershipsLevel struct{} type MembershipsLevel interface { - List([]string, string, io.Writer) error + List([]string, string, string, io.Writer) error Get([]string) ([]*youtube.MembershipsLevel, error) } @@ -46,7 +46,7 @@ func (m *membershipsLevel) Get(parts []string) ( } func (m *membershipsLevel) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { membershipsLevels, err := m.Get(parts) if err != nil { @@ -55,9 +55,9 @@ func (m *membershipsLevel) List( switch output { case "json": - utils.PrintJSON(membershipsLevels, writer) + utils.PrintJSON(membershipsLevels, jpath, writer) case "yaml": - utils.PrintYAML(membershipsLevels, writer) + utils.PrintYAML(membershipsLevels, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() diff --git a/pkg/playlist/playlist.go b/pkg/playlist/playlist.go index 5f5f7e8..88683a6 100644 --- a/pkg/playlist/playlist.go +++ b/pkg/playlist/playlist.go @@ -35,9 +35,9 @@ type playlist struct { } type Playlist interface { - List([]string, string, io.Writer) error - Insert(string, io.Writer) error - Update(string, io.Writer) error + List([]string, string, string, io.Writer) error + Insert(string, string, io.Writer) error + Update(string, string, io.Writer) error Delete(io.Writer) error Get([]string) ([]*youtube.Playlist, error) } @@ -85,7 +85,9 @@ func (p *playlist) Get(parts []string) ([]*youtube.Playlist, error) { return res.Items, nil } -func (p *playlist) List(parts []string, output string, writer io.Writer) error { +func (p *playlist) List( + parts []string, output string, jpath string, writer io.Writer, +) error { playlists, err := p.Get(parts) if err != nil { return err @@ -93,9 +95,9 @@ func (p *playlist) List(parts []string, output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(playlists, writer) + utils.PrintJSON(playlists, jpath, writer) case "yaml": - utils.PrintYAML(playlists, writer) + utils.PrintYAML(playlists, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() @@ -110,7 +112,7 @@ func (p *playlist) List(parts []string, output string, writer io.Writer) error { return nil } -func (p *playlist) Insert(output string, writer io.Writer) error { +func (p *playlist) Insert(output string, jpath string, writer io.Writer) error { upload := &youtube.Playlist{ Snippet: &youtube.PlaylistSnippet{ Title: p.Title, @@ -132,9 +134,9 @@ func (p *playlist) Insert(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Playlist inserted: %s\n", res.Id) @@ -142,7 +144,7 @@ func (p *playlist) Insert(output string, writer io.Writer) error { return nil } -func (p *playlist) Update(output string, writer io.Writer) error { +func (p *playlist) Update(output string, jpath string, writer io.Writer) error { playlists, err := p.Get([]string{"id", "snippet", "status"}) if err != nil { return errors.Join(errUpdatePlaylist, err) @@ -176,9 +178,9 @@ func (p *playlist) Update(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Playlist updated: %s\n", res.Id) diff --git a/pkg/playlistImage/playlistImage.go b/pkg/playlistImage/playlistImage.go index eb6e304..90029c7 100644 --- a/pkg/playlistImage/playlistImage.go +++ b/pkg/playlistImage/playlistImage.go @@ -36,9 +36,9 @@ type playlistImage struct { type PlaylistImage interface { Get([]string) ([]*youtube.PlaylistImage, error) - List([]string, string, io.Writer) error - Insert(string, io.Writer) error - Update(string, io.Writer) error + List([]string, string, string, io.Writer) error + Insert(string, string, io.Writer) error + Update(string, string, io.Writer) error Delete(io.Writer) error } @@ -79,7 +79,7 @@ func (pi *playlistImage) Get(parts []string) ([]*youtube.PlaylistImage, error) { } func (pi *playlistImage) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { playlistImages, err := pi.Get(parts) if err != nil { @@ -88,9 +88,9 @@ func (pi *playlistImage) List( switch output { case "json": - utils.PrintJSON(playlistImages, writer) + utils.PrintJSON(playlistImages, jpath, writer) case "yaml": - utils.PrintYAML(playlistImages, writer) + utils.PrintYAML(playlistImages, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() @@ -107,7 +107,9 @@ func (pi *playlistImage) List( return nil } -func (pi *playlistImage) Insert(output string, writer io.Writer) error { +func (pi *playlistImage) Insert( + output string, jpath string, writer io.Writer, +) error { file, err := os.Open(pi.File) if err != nil { return errors.Join(errInsertPlaylistImage, err) @@ -140,9 +142,9 @@ func (pi *playlistImage) Insert(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "PlaylistImage inserted: %s\n", res.Id) @@ -150,7 +152,9 @@ func (pi *playlistImage) Insert(output string, writer io.Writer) error { return nil } -func (pi *playlistImage) Update(output string, writer io.Writer) error { +func (pi *playlistImage) Update( + output string, jpath string, writer io.Writer, +) error { playlistImages, err := pi.Get([]string{"id", "kind", "snippet"}) if err != nil { return errors.Join(errUpdatePlaylistImage, err) @@ -194,9 +198,9 @@ func (pi *playlistImage) Update(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "PlaylistImage updated: %s\n", res.Id) diff --git a/pkg/playlistItem/playlistItem.go b/pkg/playlistItem/playlistItem.go index 990054c..deb3a68 100644 --- a/pkg/playlistItem/playlistItem.go +++ b/pkg/playlistItem/playlistItem.go @@ -36,9 +36,9 @@ type playlistItem struct { } type PlaylistItem interface { - List([]string, string, io.Writer) error - Insert(string, io.Writer) error - Update(string, io.Writer) error + List([]string, string, string, io.Writer) error + Insert(string, string, io.Writer) error + Update(string, string, io.Writer) error Delete(io.Writer) error Get([]string) ([]*youtube.PlaylistItem, error) } @@ -82,7 +82,7 @@ func (pi *playlistItem) Get(parts []string) ([]*youtube.PlaylistItem, error) { } func (pi *playlistItem) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { playlistItems, err := pi.Get(parts) if err != nil { @@ -91,9 +91,9 @@ func (pi *playlistItem) List( switch output { case "json": - utils.PrintJSON(playlistItems, writer) + utils.PrintJSON(playlistItems, jpath, writer) case "yaml": - utils.PrintYAML(playlistItems, writer) + utils.PrintYAML(playlistItems, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() @@ -121,7 +121,9 @@ func (pi *playlistItem) List( return nil } -func (pi *playlistItem) Insert(output string, writer io.Writer) error { +func (pi *playlistItem) Insert( + output string, jpath string, writer io.Writer, +) error { var resourceId *youtube.ResourceId switch pi.Kind { case "video": @@ -168,9 +170,9 @@ func (pi *playlistItem) Insert(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Playlist Item inserted: %s\n", res.Id) @@ -178,7 +180,9 @@ func (pi *playlistItem) Insert(output string, writer io.Writer) error { return nil } -func (pi *playlistItem) Update(output string, writer io.Writer) error { +func (pi *playlistItem) Update( + output string, jpath string, writer io.Writer, +) error { playlistItems, err := pi.Get([]string{"id", "snippet", "status"}) if err != nil { return errors.Join(errUpdatePlaylistItem, err) @@ -212,9 +216,9 @@ func (pi *playlistItem) Update(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Playlist Item updated: %s\n", res.Id) diff --git a/pkg/search/search.go b/pkg/search/search.go index 7c36ff0..e33fbe2 100644 --- a/pkg/search/search.go +++ b/pkg/search/search.go @@ -48,7 +48,7 @@ type search struct { type Search interface { Get([]string) ([]*youtube.SearchResult, error) - List([]string, string, io.Writer) error + List([]string, string, string, io.Writer) error } type Option func(*search) @@ -190,7 +190,9 @@ func (s *search) Get(parts []string) ([]*youtube.SearchResult, error) { return res.Items, nil } -func (s *search) List(parts []string, output string, writer io.Writer) error { +func (s *search) List( + parts []string, output string, jpath string, writer io.Writer, +) error { results, err := s.Get(parts) if err != nil { return err @@ -198,9 +200,9 @@ func (s *search) List(parts []string, output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(results, writer) + utils.PrintJSON(results, jpath, writer) case "yaml": - utils.PrintYAML(results, writer) + utils.PrintYAML(results, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() diff --git a/pkg/subscription/subscription.go b/pkg/subscription/subscription.go index 178deb8..a352d17 100644 --- a/pkg/subscription/subscription.go +++ b/pkg/subscription/subscription.go @@ -35,8 +35,8 @@ type subscription struct { type Subscription interface { Get([]string) ([]*youtube.Subscription, error) - List([]string, string, io.Writer) error - Insert(string, io.Writer) error + List([]string, string, string, io.Writer) error + Insert(string, string, io.Writer) error Delete(io.Writer) error } @@ -97,7 +97,7 @@ func (s *subscription) Get(parts []string) ([]*youtube.Subscription, error) { } func (s *subscription) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { subscriptions, err := s.Get(parts) if err != nil { @@ -106,9 +106,9 @@ func (s *subscription) List( switch output { case "json": - utils.PrintJSON(subscriptions, writer) + utils.PrintJSON(subscriptions, jpath, writer) case "yaml": - utils.PrintYAML(subscriptions, writer) + utils.PrintYAML(subscriptions, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() @@ -136,7 +136,9 @@ func (s *subscription) List( return nil } -func (s *subscription) Insert(output string, writer io.Writer) error { +func (s *subscription) Insert( + output string, jpath string, writer io.Writer, +) error { subscription := &youtube.Subscription{ Snippet: &youtube.SubscriptionSnippet{ ChannelId: s.SubscriberChannelId, @@ -156,9 +158,9 @@ func (s *subscription) Insert(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) default: _, _ = fmt.Fprintf(writer, "Subscription inserted: %s\n", res.Id) } diff --git a/pkg/superChatEvent/superChatEvent.go b/pkg/superChatEvent/superChatEvent.go index f85d864..cbf366a 100644 --- a/pkg/superChatEvent/superChatEvent.go +++ b/pkg/superChatEvent/superChatEvent.go @@ -21,7 +21,7 @@ type superChatEvent struct { type SuperChatEvent interface { Get([]string) ([]*youtube.SuperChatEvent, error) - List([]string, string, io.Writer) error + List([]string, string, string, io.Writer) error } type Option func(*superChatEvent) @@ -55,7 +55,7 @@ func (s *superChatEvent) Get(parts []string) ([]*youtube.SuperChatEvent, error) } func (s *superChatEvent) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { events, err := s.Get(parts) if err != nil { @@ -64,9 +64,9 @@ func (s *superChatEvent) List( switch output { case "json": - utils.PrintJSON(events, writer) + utils.PrintJSON(events, jpath, writer) case "yaml": - utils.PrintYAML(events, writer) + utils.PrintYAML(events, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() diff --git a/pkg/thumbnail/thumbnail.go b/pkg/thumbnail/thumbnail.go index da6d9da..78d8e0a 100644 --- a/pkg/thumbnail/thumbnail.go +++ b/pkg/thumbnail/thumbnail.go @@ -21,7 +21,7 @@ type thumbnail struct { } type Thumbnail interface { - Set(string, io.Writer) error + Set(string, string, io.Writer) error } type Option func(*thumbnail) @@ -34,7 +34,7 @@ func NewThumbnail(opts ...Option) Thumbnail { return t } -func (t *thumbnail) Set(output string, writer io.Writer) error { +func (t *thumbnail) Set(output string, jpath string, writer io.Writer) error { file, err := os.Open(t.File) if err != nil { return errors.Join(errSetThumbnail, err) @@ -48,9 +48,9 @@ func (t *thumbnail) Set(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Thumbnail set for video %s", t.VideoId) diff --git a/pkg/video/video.go b/pkg/video/video.go index c366c23..af6835d 100644 --- a/pkg/video/video.go +++ b/pkg/video/video.go @@ -63,11 +63,11 @@ type video struct { } type Video interface { - List([]string, string, io.Writer) error - Insert(string, io.Writer) error - Update(string, io.Writer) error + List([]string, string, string, io.Writer) error + Insert(string, string, io.Writer) error + Update(string, string, io.Writer) error Rate(io.Writer) error - GetRating(string, io.Writer) error + GetRating(string, string, io.Writer) error Delete(io.Writer) error ReportAbuse(io.Writer) error Get([]string) ([]*youtube.Video, error) @@ -131,7 +131,9 @@ func (v *video) Get(parts []string) ([]*youtube.Video, error) { return res.Items, nil } -func (v *video) List(parts []string, output string, writer io.Writer) error { +func (v *video) List( + parts []string, output string, jpath string, writer io.Writer, +) error { videos, err := v.Get(parts) if err != nil { return err @@ -139,9 +141,9 @@ func (v *video) List(parts []string, output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(videos, writer) + utils.PrintJSON(videos, jpath, writer) case "yaml": - utils.PrintYAML(videos, writer) + utils.PrintYAML(videos, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() @@ -162,7 +164,7 @@ func (v *video) List(parts []string, output string, writer io.Writer) error { return nil } -func (v *video) Insert(output string, writer io.Writer) error { +func (v *video) Insert(output string, jpath string, writer io.Writer) error { file, err := os.Open(v.File) if err != nil { return errors.Join(errInsertVideo, err) @@ -234,7 +236,7 @@ func (v *video) Insert(output string, writer io.Writer) error { thumbnail.WithFile(v.Thumbnail), thumbnail.WithService(service), ) - t.Set("silent", nil) + _ = t.Set("silent", "", nil) } if v.PlaylistId != "" { @@ -249,14 +251,14 @@ func (v *video) Insert(output string, writer io.Writer) error { playlistItem.WithService(service), ) - _ = pi.Insert("silent", writer) + _ = pi.Insert("silent", "", writer) } switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Video inserted: %s\n", res.Id) @@ -264,7 +266,7 @@ func (v *video) Insert(output string, writer io.Writer) error { return nil } -func (v *video) Update(output string, writer io.Writer) error { +func (v *video) Update(output string, jpath string, writer io.Writer) error { videos, err := v.Get([]string{"id", "snippet", "status"}) if err != nil { return errors.Join(errUpdateVideo, err) @@ -319,7 +321,7 @@ func (v *video) Update(output string, writer io.Writer) error { thumbnail.WithFile(v.Thumbnail), thumbnail.WithService(service), ) - t.Set("silent", nil) + _ = t.Set("silent", "", nil) } if v.PlaylistId != "" { @@ -334,14 +336,14 @@ func (v *video) Update(output string, writer io.Writer) error { playlistItem.WithService(service), ) - _ = pi.Insert("silent", writer) + _ = pi.Insert("silent", "", writer) } switch output { case "json": - utils.PrintJSON(res, writer) + utils.PrintJSON(res, jpath, writer) case "yaml": - utils.PrintYAML(res, writer) + utils.PrintYAML(res, jpath, writer) case "silent": default: _, _ = fmt.Fprintf(writer, "Video updated: %s\n", res.Id) @@ -361,7 +363,7 @@ func (v *video) Rate(writer io.Writer) error { return nil } -func (v *video) GetRating(output string, writer io.Writer) error { +func (v *video) GetRating(output string, jpath string, writer io.Writer) error { call := service.Videos.GetRating(v.IDs) if v.OnBehalfOfContentOwner != "" { call = call.OnBehalfOfContentOwner(v.OnBehalfOfContentOwnerChannel) @@ -373,9 +375,9 @@ func (v *video) GetRating(output string, writer io.Writer) error { switch output { case "json": - utils.PrintJSON(res.Items, writer) + utils.PrintJSON(res.Items, jpath, writer) case "yaml": - utils.PrintYAML(res.Items, writer) + utils.PrintYAML(res.Items, jpath, writer) default: _, _ = fmt.Fprintln(writer, "ID\tRating") for _, item := range res.Items { diff --git a/pkg/videoAbuseReportReason/videoAbuseReportReason.go b/pkg/videoAbuseReportReason/videoAbuseReportReason.go index 0c76185..24a5b90 100644 --- a/pkg/videoAbuseReportReason/videoAbuseReportReason.go +++ b/pkg/videoAbuseReportReason/videoAbuseReportReason.go @@ -20,7 +20,7 @@ type videoAbuseReportReason struct { type VideoAbuseReportReason interface { Get([]string) ([]*youtube.VideoAbuseReportReason, error) - List([]string, string, io.Writer) error + List([]string, string, string, io.Writer) error } type Option func(*videoAbuseReportReason) @@ -50,7 +50,7 @@ func (va *videoAbuseReportReason) Get(parts []string) ( } func (va *videoAbuseReportReason) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { videoAbuseReportReasons, err := va.Get(parts) if err != nil { @@ -59,9 +59,9 @@ func (va *videoAbuseReportReason) List( switch output { case "json": - utils.PrintJSON(videoAbuseReportReasons, writer) + utils.PrintJSON(videoAbuseReportReasons, jpath, writer) case "yaml": - utils.PrintYAML(videoAbuseReportReasons, writer) + utils.PrintYAML(videoAbuseReportReasons, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() diff --git a/pkg/videoCategory/videoCategory.go b/pkg/videoCategory/videoCategory.go index 9389095..8482a9c 100644 --- a/pkg/videoCategory/videoCategory.go +++ b/pkg/videoCategory/videoCategory.go @@ -22,7 +22,7 @@ type videoCategory struct { type VideoCategory interface { Get([]string) ([]*youtube.VideoCategory, error) - List([]string, string, io.Writer) error + List([]string, string, string, io.Writer) error } type Option func(*videoCategory) @@ -56,7 +56,7 @@ func (vc *videoCategory) Get(parts []string) ([]*youtube.VideoCategory, error) { } func (vc *videoCategory) List( - parts []string, output string, writer io.Writer, + parts []string, output string, jpath string, writer io.Writer, ) error { videoCategories, err := vc.Get(parts) if err != nil { @@ -65,9 +65,9 @@ func (vc *videoCategory) List( switch output { case "json": - utils.PrintJSON(videoCategories, writer) + utils.PrintJSON(videoCategories, jpath, writer) case "yaml": - utils.PrintYAML(videoCategories, writer) + utils.PrintYAML(videoCategories, jpath, writer) case "table": tb := table.NewWriter() defer tb.Render() diff --git a/pkg/watermark/watermark.go b/pkg/watermark/watermark.go index d2cdce8..c82e06b 100644 --- a/pkg/watermark/watermark.go +++ b/pkg/watermark/watermark.go @@ -26,7 +26,7 @@ type watermark struct { } type Watermark interface { - Set(io.Writer) error + Set(string, io.Writer) error Unset(io.Writer) error } @@ -42,7 +42,7 @@ func NewWatermark(opts ...Option) Watermark { return w } -func (w *watermark) Set(writer io.Writer) error { +func (w *watermark) Set(s string, writer io.Writer) error { file, err := os.Open(w.File) if err != nil { return errors.Join(errSetWatermark, err)