From e363da27351c85ec2174907cec510c2e1bc5a72f Mon Sep 17 00:00:00 2001 From: OpenWaygate <27287694+OpenWaygate@users.noreply.github.com> Date: Thu, 20 Aug 2026 22:18:48 +0800 Subject: [PATCH] :recycle: Cleanup unused code --- cmd/BUILD.bazel | 14 +--- cmd/abuseReport/abuseReport.go | 2 +- cmd/activity/activity.go | 2 +- cmd/activity/list.go | 2 +- cmd/agent/agent.go | 2 +- cmd/auth.go | 2 +- cmd/caption/caption.go | 4 +- cmd/caption/download.go | 2 +- cmd/caption/list.go | 2 +- cmd/channel/channel.go | 2 +- cmd/channel/list.go | 2 +- cmd/channelBanner/channelBanner.go | 2 +- cmd/channelSection/channelSection.go | 4 +- cmd/channelSection/list.go | 2 +- cmd/comment/comment.go | 4 +- cmd/comment/list.go | 2 +- cmd/commentThread/commentThread.go | 2 +- cmd/commentThread/list.go | 2 +- cmd/i18nLanguage/i18nLanguage.go | 2 +- cmd/i18nLanguage/list.go | 2 +- cmd/i18nRegion/i18nRegion.go | 2 +- cmd/i18nRegion/list.go | 2 +- cmd/liveBroadcast/list.go | 2 +- cmd/liveBroadcast/liveBroadcast.go | 4 +- cmd/liveChatBan/liveChatBan.go | 2 +- cmd/liveChatMessage/list.go | 2 +- cmd/liveChatMessage/liveChatMessage.go | 2 +- cmd/liveChatModerator/list.go | 2 +- cmd/liveChatModerator/liveChatModerator.go | 2 +- cmd/liveStream/list.go | 2 +- cmd/liveStream/liveStream.go | 4 +- cmd/mcp.go | 2 +- cmd/member/list.go | 2 +- cmd/member/member.go | 2 +- cmd/membershipsLevel/list.go | 2 +- cmd/membershipsLevel/membershipsLevel.go | 2 +- cmd/playlist/list.go | 2 +- cmd/playlist/playlist.go | 4 +- cmd/playlistImage/list.go | 2 +- cmd/playlistImage/playlistImage.go | 2 +- cmd/playlistItem/list.go | 2 +- cmd/playlistItem/playlistItem.go | 2 +- cmd/root.go | 2 +- cmd/search/list.go | 2 +- cmd/search/search.go | 2 +- cmd/subscription/list.go | 2 +- cmd/subscription/subscription.go | 2 +- cmd/superChatEvent/list.go | 2 +- cmd/superChatEvent/superChatEvent.go | 2 +- cmd/thirdPartyLink/list.go | 2 +- cmd/thirdPartyLink/thirdPartyLink.go | 2 +- cmd/thumbnail/thumbnail.go | 2 +- cmd/version.go | 2 +- cmd/video/getRating.go | 2 +- cmd/video/list.go | 2 +- cmd/video/video.go | 4 +- cmd/videoAbuseReportReason/list.go | 2 +- .../videoAbuseReportReason.go | 2 +- cmd/videoCategory/list.go | 2 +- cmd/videoCategory/videoCategory.go | 2 +- cmd/watermark/watermark.go | 2 +- pkg/utils/utils_test.go | 65 ++++++++++--------- 62 files changed, 102 insertions(+), 111 deletions(-) diff --git a/cmd/BUILD.bazel b/cmd/BUILD.bazel index 215a2f4..7eb7869 100644 --- a/cmd/BUILD.bazel +++ b/cmd/BUILD.bazel @@ -1,10 +1,9 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_library") go_library( name = "cmd", srcs = [ "auth.go", - "flags.go", "mcp.go", "root.go", "version.go", @@ -23,19 +22,8 @@ go_library( "//pkg", "//pkg/auth", "//pkg/common", - "//pkg/utils", "@com_github_eat_pray_ai_cobra_mcp//:cobra-mcp", "@com_github_savioxavier_termlink//:termlink", "@com_github_spf13_cobra//:cobra", ], ) - -go_test( - name = "cmd_test", - srcs = ["flags_test.go"], - embed = [":cmd"], - deps = [ - "//pkg/utils", - "@com_github_spf13_cobra//:cobra", - ], -) diff --git a/cmd/abuseReport/abuseReport.go b/cmd/abuseReport/abuseReport.go index 09469a3..13cb204 100644 --- a/cmd/abuseReport/abuseReport.go +++ b/cmd/abuseReport/abuseReport.go @@ -33,7 +33,7 @@ var abuseReportCmd = &cobra.Command{ Use: "abuseReport", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/activity/activity.go b/cmd/activity/activity.go index 1d8496a..c5a85d1 100644 --- a/cmd/activity/activity.go +++ b/cmd/activity/activity.go @@ -32,7 +32,7 @@ var activityCmd = &cobra.Command{ Use: "activity", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/activity/list.go b/cmd/activity/list.go index feb2d0c..3c1985c 100644 --- a/cmd/activity/list.go +++ b/cmd/activity/list.go @@ -96,7 +96,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := activity.NewActivity( activity.WithChannelId(channelId), diff --git a/cmd/agent/agent.go b/cmd/agent/agent.go index 04cbe8d..c1958ba 100644 --- a/cmd/agent/agent.go +++ b/cmd/agent/agent.go @@ -54,7 +54,7 @@ var agentCmd = &cobra.Command{ Short: short, Long: long, Example: example, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { if launcherArgs == "" { _ = cmd.Help() return diff --git a/cmd/auth.go b/cmd/auth.go index 1697085..cd9ed44 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -30,7 +30,7 @@ var authCmd = &cobra.Command{ Use: "auth", Short: authShort, Long: authLong, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { redirectURL := fmt.Sprintf("http://localhost:%d", authPort) if _, err := auth.NewY2BService( auth.WithCredential(credential, pkg.Root.FS()), diff --git a/cmd/caption/caption.go b/cmd/caption/caption.go index 24b0f78..5064e11 100644 --- a/cmd/caption/caption.go +++ b/cmd/caption/caption.go @@ -52,10 +52,10 @@ var captionCmd = &cobra.Command{ Use: "caption", Short: short, Long: long, - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(cmd *cobra.Command, _ []string) { resetFlags(cmd.Flags()) }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/caption/download.go b/cmd/caption/download.go index 629c896..6395544 100644 --- a/cmd/caption/download.go +++ b/cmd/caption/download.go @@ -87,7 +87,7 @@ var downloadCmd = &cobra.Command{ Short: downloadShort, Long: downloadLong, Example: downloadExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { input := caption.NewCaption( caption.WithIds(ids), caption.WithFile(file), diff --git a/cmd/caption/list.go b/cmd/caption/list.go index 42eb4ab..a5d5c26 100644 --- a/cmd/caption/list.go +++ b/cmd/caption/list.go @@ -89,7 +89,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := caption.NewCaption( caption.WithIds(ids), diff --git a/cmd/channel/channel.go b/cmd/channel/channel.go index b536ad0..302a15b 100644 --- a/cmd/channel/channel.go +++ b/cmd/channel/channel.go @@ -45,7 +45,7 @@ var channelCmd = &cobra.Command{ Use: "channel", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/channel/list.go b/cmd/channel/list.go index 4bc481b..5dc78de 100644 --- a/cmd/channel/list.go +++ b/cmd/channel/list.go @@ -114,7 +114,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := channel.NewChannel( channel.WithCategoryId(categoryId), diff --git a/cmd/channelBanner/channelBanner.go b/cmd/channelBanner/channelBanner.go index 7d68ce3..6fcf6ee 100644 --- a/cmd/channelBanner/channelBanner.go +++ b/cmd/channelBanner/channelBanner.go @@ -27,7 +27,7 @@ var channelBannerCmd = &cobra.Command{ Use: "channelBanner", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/channelSection/channelSection.go b/cmd/channelSection/channelSection.go index 481a803..c46aff1 100644 --- a/cmd/channelSection/channelSection.go +++ b/cmd/channelSection/channelSection.go @@ -30,10 +30,10 @@ var channelSectionCmd = &cobra.Command{ Use: "channelSection", Short: short, Long: long, - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(cmd *cobra.Command, _ []string) { utils.ResetBool(map[string]**bool{"mine": &mine}, cmd.Flags()) }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/channelSection/list.go b/cmd/channelSection/list.go index 4ce1bab..5c26494 100644 --- a/cmd/channelSection/list.go +++ b/cmd/channelSection/list.go @@ -91,7 +91,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := channelSection.NewChannelSection( channelSection.WithIds(ids), diff --git a/cmd/comment/comment.go b/cmd/comment/comment.go index a67f387..24ce2ea 100644 --- a/cmd/comment/comment.go +++ b/cmd/comment/comment.go @@ -44,11 +44,11 @@ var commentCmd = &cobra.Command{ Use: "comment", Short: short, Long: long, - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(cmd *cobra.Command, _ []string) { boolMap := map[string]**bool{"canRate": &canRate, "banAuthor": &banAuthor} utils.ResetBool(boolMap, cmd.Flags()) }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/comment/list.go b/cmd/comment/list.go index 34f4aad..f69e9cb 100644 --- a/cmd/comment/list.go +++ b/cmd/comment/list.go @@ -97,7 +97,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := comment.NewComment( comment.WithIds(ids), diff --git a/cmd/commentThread/commentThread.go b/cmd/commentThread/commentThread.go index d9daf95..7353101 100644 --- a/cmd/commentThread/commentThread.go +++ b/cmd/commentThread/commentThread.go @@ -41,7 +41,7 @@ var commentThreadCmd = &cobra.Command{ Use: "commentThread", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/commentThread/list.go b/cmd/commentThread/list.go index dd16b7d..5659c0f 100644 --- a/cmd/commentThread/list.go +++ b/cmd/commentThread/list.go @@ -118,7 +118,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := commentThread.NewCommentThread( commentThread.WithIds(ids), diff --git a/cmd/i18nLanguage/i18nLanguage.go b/cmd/i18nLanguage/i18nLanguage.go index 4ab7d87..2d3097a 100644 --- a/cmd/i18nLanguage/i18nLanguage.go +++ b/cmd/i18nLanguage/i18nLanguage.go @@ -29,7 +29,7 @@ var i18nLanguageCmd = &cobra.Command{ Use: "i18nLanguage", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/i18nLanguage/list.go b/cmd/i18nLanguage/list.go index 20d0c9e..f8f733e 100644 --- a/cmd/i18nLanguage/list.go +++ b/cmd/i18nLanguage/list.go @@ -55,7 +55,7 @@ var listCmd = &cobra.Command{ Use: "list", Short: listShort, Long: listLong, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := i18nLanguage.NewI18nLanguage( i18nLanguage.WithHl(hl), diff --git a/cmd/i18nRegion/i18nRegion.go b/cmd/i18nRegion/i18nRegion.go index dfdfbb3..007c099 100644 --- a/cmd/i18nRegion/i18nRegion.go +++ b/cmd/i18nRegion/i18nRegion.go @@ -26,7 +26,7 @@ var i18nRegionCmd = &cobra.Command{ Use: "i18nRegion", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/i18nRegion/list.go b/cmd/i18nRegion/list.go index 99e3f48..e7b00b7 100644 --- a/cmd/i18nRegion/list.go +++ b/cmd/i18nRegion/list.go @@ -44,7 +44,7 @@ var listCmd = &cobra.Command{ Use: "list", Short: listShort, Long: listLong, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := i18nRegion.NewI18nRegion( i18nRegion.WithHl(hl), diff --git a/cmd/liveBroadcast/list.go b/cmd/liveBroadcast/list.go index a7850fd..c80b161 100644 --- a/cmd/liveBroadcast/list.go +++ b/cmd/liveBroadcast/list.go @@ -107,7 +107,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := liveBroadcast.NewLiveBroadcast( liveBroadcast.WithIds(ids), diff --git a/cmd/liveBroadcast/liveBroadcast.go b/cmd/liveBroadcast/liveBroadcast.go index 4e6dc6b..0a8afce 100644 --- a/cmd/liveBroadcast/liveBroadcast.go +++ b/cmd/liveBroadcast/liveBroadcast.go @@ -53,10 +53,10 @@ var liveBroadcastCmd = &cobra.Command{ Use: "liveBroadcast", Short: short, Long: long, - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(cmd *cobra.Command, _ []string) { resetFlags(cmd.Flags()) }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/liveChatBan/liveChatBan.go b/cmd/liveChatBan/liveChatBan.go index e92f0ed..5a23a48 100644 --- a/cmd/liveChatBan/liveChatBan.go +++ b/cmd/liveChatBan/liveChatBan.go @@ -30,7 +30,7 @@ var liveChatBanCmd = &cobra.Command{ Use: "liveChatBan", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/liveChatMessage/list.go b/cmd/liveChatMessage/list.go index b2f8f2c..b8e1801 100644 --- a/cmd/liveChatMessage/list.go +++ b/cmd/liveChatMessage/list.go @@ -86,7 +86,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := liveChatMessage.NewLiveChatMessage( liveChatMessage.WithLiveChatId(liveChatId), diff --git a/cmd/liveChatMessage/liveChatMessage.go b/cmd/liveChatMessage/liveChatMessage.go index 6693b19..a8ff1e1 100644 --- a/cmd/liveChatMessage/liveChatMessage.go +++ b/cmd/liveChatMessage/liveChatMessage.go @@ -30,7 +30,7 @@ var liveChatMessageCmd = &cobra.Command{ Use: "liveChatMessage", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/liveChatModerator/list.go b/cmd/liveChatModerator/list.go index 3bcf623..9491b84 100644 --- a/cmd/liveChatModerator/list.go +++ b/cmd/liveChatModerator/list.go @@ -82,7 +82,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := liveChatModerator.NewLiveChatModerator( liveChatModerator.WithLiveChatId(liveChatId), diff --git a/cmd/liveChatModerator/liveChatModerator.go b/cmd/liveChatModerator/liveChatModerator.go index fbe96b0..94da99f 100644 --- a/cmd/liveChatModerator/liveChatModerator.go +++ b/cmd/liveChatModerator/liveChatModerator.go @@ -27,7 +27,7 @@ var liveChatModeratorCmd = &cobra.Command{ Use: "liveChatModerator", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/liveStream/list.go b/cmd/liveStream/list.go index be1f94c..9dad38e 100644 --- a/cmd/liveStream/list.go +++ b/cmd/liveStream/list.go @@ -101,7 +101,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := liveStream.NewLiveStream( liveStream.WithIds(ids), diff --git a/cmd/liveStream/liveStream.go b/cmd/liveStream/liveStream.go index 6a6c375..a6d44c4 100644 --- a/cmd/liveStream/liveStream.go +++ b/cmd/liveStream/liveStream.go @@ -39,10 +39,10 @@ var liveStreamCmd = &cobra.Command{ Use: "liveStream", Short: short, Long: long, - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(cmd *cobra.Command, _ []string) { resetFlags(cmd.Flags()) }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/mcp.go b/cmd/mcp.go index 51f8a8c..9525ba2 100644 --- a/cmd/mcp.go +++ b/cmd/mcp.go @@ -39,7 +39,7 @@ func init() { "Enable MCP OAuth authorization (HTTP mode only)", ) - mcpCmd.PreRunE = func(cmd *cobra.Command, args []string) error { + mcpCmd.PreRunE = func(cmd *cobra.Command, _ []string) error { if mcpAuth { mcpConfig.Auth = &cobramcp.AuthConfig{ TokenVerifier: auth.GoogleTokenVerifier, diff --git a/cmd/member/list.go b/cmd/member/list.go index 0814ac6..3bf2bae 100644 --- a/cmd/member/list.go +++ b/cmd/member/list.go @@ -92,7 +92,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := member.NewMember( member.WithMemberChannelId(memberChannelId), diff --git a/cmd/member/member.go b/cmd/member/member.go index a65843c..69c973d 100644 --- a/cmd/member/member.go +++ b/cmd/member/member.go @@ -28,7 +28,7 @@ var memberCmd = &cobra.Command{ Use: "member", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/membershipsLevel/list.go b/cmd/membershipsLevel/list.go index 7c740a2..9bf34f3 100644 --- a/cmd/membershipsLevel/list.go +++ b/cmd/membershipsLevel/list.go @@ -71,7 +71,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := membershipsLevel.NewMembershipsLevel( membershipsLevel.WithParts(parts), diff --git a/cmd/membershipsLevel/membershipsLevel.go b/cmd/membershipsLevel/membershipsLevel.go index 4abe487..7be2053 100644 --- a/cmd/membershipsLevel/membershipsLevel.go +++ b/cmd/membershipsLevel/membershipsLevel.go @@ -21,7 +21,7 @@ var membershipsLevelCmd = &cobra.Command{ Use: "membershipsLevel", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/playlist/list.go b/cmd/playlist/list.go index c3a5110..e49bb94 100644 --- a/cmd/playlist/list.go +++ b/cmd/playlist/list.go @@ -110,7 +110,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := playlist.NewPlaylist( playlist.WithIds(ids), diff --git a/cmd/playlist/playlist.go b/cmd/playlist/playlist.go index ea677ac..82ea77d 100644 --- a/cmd/playlist/playlist.go +++ b/cmd/playlist/playlist.go @@ -43,10 +43,10 @@ var playlistCmd = &cobra.Command{ Use: "playlist", Short: short, Long: long, - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(cmd *cobra.Command, _ []string) { utils.ResetBool(map[string]**bool{"mine": &mine}, cmd.Flags()) }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/playlistImage/list.go b/cmd/playlistImage/list.go index 2d59c9e..d8d8f49 100644 --- a/cmd/playlistImage/list.go +++ b/cmd/playlistImage/list.go @@ -94,7 +94,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := playlistImage.NewPlaylistImage( playlistImage.WithParent(parent), diff --git a/cmd/playlistImage/playlistImage.go b/cmd/playlistImage/playlistImage.go index 2918401..17e39df 100644 --- a/cmd/playlistImage/playlistImage.go +++ b/cmd/playlistImage/playlistImage.go @@ -39,7 +39,7 @@ var playlistImageCmd = &cobra.Command{ Use: "playlistImage", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/playlistItem/list.go b/cmd/playlistItem/list.go index c49aa9c..855b886 100644 --- a/cmd/playlistItem/list.go +++ b/cmd/playlistItem/list.go @@ -95,7 +95,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := playlistItem.NewPlaylistItem( playlistItem.WithIds(ids), diff --git a/cmd/playlistItem/playlistItem.go b/cmd/playlistItem/playlistItem.go index 74f69dd..a2b3f71 100644 --- a/cmd/playlistItem/playlistItem.go +++ b/cmd/playlistItem/playlistItem.go @@ -44,7 +44,7 @@ var playlistItemCmd = &cobra.Command{ Use: "playlistItem", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/root.go b/cmd/root.go index 5a20112..bf3c469 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -25,7 +25,7 @@ var RootCmd = &cobra.Command{ Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/search/list.go b/cmd/search/list.go index 9adbd79..2dca69b 100644 --- a/cmd/search/list.go +++ b/cmd/search/list.go @@ -193,7 +193,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := search.NewSearch( search.WithChannelId(channelId), diff --git a/cmd/search/search.go b/cmd/search/search.go index 15b244a..da8a6ef 100644 --- a/cmd/search/search.go +++ b/cmd/search/search.go @@ -73,7 +73,7 @@ var searchCmd = &cobra.Command{ Use: "search", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/subscription/list.go b/cmd/subscription/list.go index b5a517f..068a848 100644 --- a/cmd/subscription/list.go +++ b/cmd/subscription/list.go @@ -121,7 +121,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := subscription.NewSubscription( subscription.WithIds(ids), diff --git a/cmd/subscription/subscription.go b/cmd/subscription/subscription.go index 073af6e..a2cda8d 100644 --- a/cmd/subscription/subscription.go +++ b/cmd/subscription/subscription.go @@ -38,7 +38,7 @@ var subscriptionCmd = &cobra.Command{ Use: "subscription", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/superChatEvent/list.go b/cmd/superChatEvent/list.go index e2d9861..f2bd7c5 100644 --- a/cmd/superChatEvent/list.go +++ b/cmd/superChatEvent/list.go @@ -79,7 +79,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := superChatEvent.NewSuperChatEvent( superChatEvent.WithHl(hl), diff --git a/cmd/superChatEvent/superChatEvent.go b/cmd/superChatEvent/superChatEvent.go index 8ea8695..79dd090 100644 --- a/cmd/superChatEvent/superChatEvent.go +++ b/cmd/superChatEvent/superChatEvent.go @@ -24,7 +24,7 @@ var superChatEventCmd = &cobra.Command{ Use: "superChatEvent", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/thirdPartyLink/list.go b/cmd/thirdPartyLink/list.go index 7ccc403..ad06dd1 100644 --- a/cmd/thirdPartyLink/list.go +++ b/cmd/thirdPartyLink/list.go @@ -83,7 +83,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := thirdPartyLink.NewThirdPartyLink( thirdPartyLink.WithLinkingToken(linkingToken), diff --git a/cmd/thirdPartyLink/thirdPartyLink.go b/cmd/thirdPartyLink/thirdPartyLink.go index 207bc81..97b2f99 100644 --- a/cmd/thirdPartyLink/thirdPartyLink.go +++ b/cmd/thirdPartyLink/thirdPartyLink.go @@ -29,7 +29,7 @@ var thirdPartyLinkCmd = &cobra.Command{ Use: "thirdPartyLink", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/thumbnail/thumbnail.go b/cmd/thumbnail/thumbnail.go index 318c8f5..69b6f37 100644 --- a/cmd/thumbnail/thumbnail.go +++ b/cmd/thumbnail/thumbnail.go @@ -24,7 +24,7 @@ var thumbnailCmd = &cobra.Command{ Use: "thumbnail", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/version.go b/cmd/version.go index 404169d..82e637f 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -30,7 +30,7 @@ var versionCmd = &cobra.Command{ Use: "version", Short: verShort, Long: verLong, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { info, ok := debug.ReadBuildInfo() if ok && Version == "" { Version = info.Main.Version diff --git a/cmd/video/getRating.go b/cmd/video/getRating.go index f3c2e48..2b7949e 100644 --- a/cmd/video/getRating.go +++ b/cmd/video/getRating.go @@ -75,7 +75,7 @@ var getRatingCmd = &cobra.Command{ Short: getRatingShort, Long: getRatingLong, Example: getRatingExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := video.NewVideo( video.WithIds(ids), diff --git a/cmd/video/list.go b/cmd/video/list.go index 9f9cf87..a861f13 100644 --- a/cmd/video/list.go +++ b/cmd/video/list.go @@ -116,7 +116,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := video.NewVideo( video.WithIds(ids), diff --git a/cmd/video/video.go b/cmd/video/video.go index 5a9ffb8..434bbbc 100644 --- a/cmd/video/video.go +++ b/cmd/video/video.go @@ -87,10 +87,10 @@ var videoCmd = &cobra.Command{ Use: "video", Short: short, Long: long, - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(cmd *cobra.Command, _ []string) { resetFlags(cmd.Flags()) }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/videoAbuseReportReason/list.go b/cmd/videoAbuseReportReason/list.go index 850bd2c..8a97b41 100644 --- a/cmd/videoAbuseReportReason/list.go +++ b/cmd/videoAbuseReportReason/list.go @@ -75,7 +75,7 @@ var listCmd = &cobra.Command{ Short: listShort, Long: listLong, Example: listExample, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := videoAbuseReportReason.NewVideoAbuseReportReason( videoAbuseReportReason.WithHL(hl), diff --git a/cmd/videoAbuseReportReason/videoAbuseReportReason.go b/cmd/videoAbuseReportReason/videoAbuseReportReason.go index 7ace601..1a1ebd7 100644 --- a/cmd/videoAbuseReportReason/videoAbuseReportReason.go +++ b/cmd/videoAbuseReportReason/videoAbuseReportReason.go @@ -23,7 +23,7 @@ var videoAbuseReportReasonCmd = &cobra.Command{ Use: "videoAbuseReportReason", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/videoCategory/list.go b/cmd/videoCategory/list.go index ef6bc01..cc9ff99 100644 --- a/cmd/videoCategory/list.go +++ b/cmd/videoCategory/list.go @@ -47,7 +47,7 @@ var listCmd = &cobra.Command{ Use: "list", Short: listShort, Long: listLong, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output, _ := cmd.Flags().GetString("output") input := videoCategory.NewVideoCategory( videoCategory.WithIds(ids), diff --git a/cmd/videoCategory/videoCategory.go b/cmd/videoCategory/videoCategory.go index d622eb8..d03c1f1 100644 --- a/cmd/videoCategory/videoCategory.go +++ b/cmd/videoCategory/videoCategory.go @@ -30,7 +30,7 @@ var videoCategoryCmd = &cobra.Command{ Use: "videoCategory", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/cmd/watermark/watermark.go b/cmd/watermark/watermark.go index d3b391b..be986e0 100644 --- a/cmd/watermark/watermark.go +++ b/cmd/watermark/watermark.go @@ -33,7 +33,7 @@ var watermarkCmd = &cobra.Command{ Use: "watermark", Short: short, Long: long, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { _ = cmd.Help() }, } diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go index be97e09..33444cd 100644 --- a/pkg/utils/utils_test.go +++ b/pkg/utils/utils_test.go @@ -168,14 +168,16 @@ func TestIsInteractive(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.ci != "" { - t.Setenv("CI", tt.ci) - } - if got := IsInteractive(tt.writer); got != tt.want { - t.Errorf("IsInteractive() = %v, want %v", got, tt.want) - } - }) + t.Run( + tt.name, func(t *testing.T) { + if tt.ci != "" { + t.Setenv("CI", tt.ci) + } + if got := IsInteractive(tt.writer); got != tt.want { + t.Errorf("IsInteractive() = %v, want %v", got, tt.want) + } + }, + ) } } @@ -392,14 +394,13 @@ func TestRandomStage(t *testing.T) { } } - func TestConfirmPreRun(t *testing.T) { tests := []struct { - name string - yes bool - input string + name string + yes bool + input string interactive bool - wantErr error + wantErr error }{ { name: "yes flag bypasses prompt", @@ -450,26 +451,28 @@ func TestConfirmPreRun(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - orig := IsInteractive - IsInteractive = func(any) bool { return tt.interactive } - defer func() { IsInteractive = orig }() + t.Run( + tt.name, func(t *testing.T) { + orig := IsInteractive + IsInteractive = func(any) bool { return tt.interactive } + defer func() { IsInteractive = orig }() - cmd := &cobra.Command{Use: "test"} - cmd.Flags().Bool("yes", false, "") - if tt.yes { - _ = cmd.Flags().Set("yes", "true") - } + cmd := &cobra.Command{Use: "test"} + cmd.Flags().Bool("yes", false, "") + if tt.yes { + _ = cmd.Flags().Set("yes", "true") + } - var errBuf bytes.Buffer - cmd.SetErr(&errBuf) - cmd.SetIn(strings.NewReader(tt.input)) + var errBuf bytes.Buffer + cmd.SetErr(&errBuf) + cmd.SetIn(strings.NewReader(tt.input)) - err := ConfirmPreRun(cmd, "Would do something") - if err != tt.wantErr { - t.Errorf("ConfirmPreRun() error = %v, want %v", err, tt.wantErr) - } - }) + err := ConfirmPreRun(cmd, "Would do something") + if err != tt.wantErr { + t.Errorf("ConfirmPreRun() error = %v, want %v", err, tt.wantErr) + } + }, + ) } } @@ -502,7 +505,7 @@ func TestHandleCmdError(t *testing.T) { cmd.SetOut(&outBuf) cmd.SetErr(&errBuf) cmd.SetHelpFunc( - func(c *cobra.Command, args []string) { + func(c *cobra.Command, _ []string) { _, _ = fmt.Fprint(c.OutOrStdout(), "help called") }, )