♻️ Cleanup unused code
This commit is contained in:
1 parent
8bf6457508
commit
e363da2735
62 files changed
+102
-111
No files matched your search
+1
-13
@@ -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",
|
||||
],
|
||||
)
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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()),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
+1
-1
@@ -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,
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
+1
-1
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
+2
-2
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
+34
-31
@@ -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")
|
||||
},
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user