Skip to content

Commit 8a69df7

Browse files
committed
🐛 Fix shared output flag variable masking across cmd packages
1 parent 87026c4 commit 8a69df7

60 files changed

Lines changed: 78 additions & 62 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/activity/activity.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ var (
2929
publishedBefore string
3030
regionCode string
3131
parts []string
32-
output string
3332
)
3433

3534
var activityCmd = &cobra.Command{

cmd/activity/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func init() {
8787
&parts, "parts", "p", []string{"id", "snippet", "contentDetails"},
8888
pkg.PartsUsage,
8989
)
90-
listCmd.Flags().StringVarP(&output, "output", "o", "table", pkg.TableUsage)
90+
listCmd.Flags().StringP("output", "o", "table", pkg.TableUsage)
9191
}
9292

9393
var listCmd = &cobra.Command{
@@ -96,6 +96,7 @@ var listCmd = &cobra.Command{
9696
Long: listLong,
9797
Example: listExample,
9898
Run: func(cmd *cobra.Command, args []string) {
99+
output, _ := cmd.Flags().GetString("output")
99100
input := activity.NewActivity(
100101
activity.WithChannelId(channelId),
101102
activity.WithHome(home),

cmd/caption/caption.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ var (
4646
parts []string
4747
tfmt string
4848
tlang string
49-
output string
5049
)
5150

5251
var captionCmd = &cobra.Command{

cmd/caption/insert.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func init() {
103103
insertCmd.Flags().StringVarP(
104104
&onBehalfOfContentOwner, "onBehalfOfContentOwner", "B", "", pkg.OBOCOUsage,
105105
)
106-
insertCmd.Flags().StringVarP(&output, "output", "o", "", pkg.SilentUsage)
106+
insertCmd.Flags().StringP("output", "o", "", pkg.SilentUsage)
107107

108108
_ = insertCmd.MarkFlagRequired("file")
109109
_ = insertCmd.MarkFlagRequired("videoId")
@@ -116,6 +116,7 @@ var insertCmd = &cobra.Command{
116116
Long: insertLong,
117117
Example: insertExample,
118118
Run: func(c *cobra.Command, args []string) {
119+
output, _ := c.Flags().GetString("output")
119120
err := cmd.Confirm(c, "Would insert caption")
120121
if err != nil {
121122
utils.HandleCmdError(err, c)

cmd/caption/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func init() {
8181
listCmd.Flags().StringSliceVarP(
8282
&parts, "parts", "p", []string{"id", "snippet"}, pkg.PartsUsage,
8383
)
84-
listCmd.Flags().StringVarP(&output, "output", "o", "table", pkg.TableUsage)
84+
listCmd.Flags().StringP("output", "o", "table", pkg.TableUsage)
8585
}
8686

8787
var listCmd = &cobra.Command{
@@ -90,6 +90,7 @@ var listCmd = &cobra.Command{
9090
Long: listLong,
9191
Example: listExample,
9292
Run: func(cmd *cobra.Command, args []string) {
93+
output, _ := cmd.Flags().GetString("output")
9394
input := caption.NewCaption(
9495
caption.WithIds(ids),
9596
caption.WithVideoId(videoId),

cmd/caption/update.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func init() {
102102
updateCmd.Flags().StringVarP(
103103
&onBehalfOfContentOwner, "onBehalfOfContentOwner", "B", "", pkg.OBOCOUsage,
104104
)
105-
updateCmd.Flags().StringVarP(&output, "output", "o", "", pkg.SilentUsage)
105+
updateCmd.Flags().StringP("output", "o", "", pkg.SilentUsage)
106106

107107
_ = updateCmd.MarkFlagRequired("videoId")
108108
cmd.AddMutationFlags(updateCmd)
@@ -114,6 +114,7 @@ var updateCmd = &cobra.Command{
114114
Long: updateLong,
115115
Example: updateExample,
116116
Run: func(c *cobra.Command, args []string) {
117+
output, _ := c.Flags().GetString("output")
117118
err := cmd.Confirm(c, "Would update caption for video: %s", videoId)
118119
if err != nil {
119120
utils.HandleCmdError(err, c)

cmd/channel/channel.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ var (
4444
description string
4545
title string
4646
parts []string
47-
output string
4847

4948
onBehalfOfContentOwner string
5049
)

cmd/channel/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func init() {
111111
listCmd.Flags().StringSliceVarP(
112112
&parts, "parts", "p", []string{"id", "snippet", "status"}, pkg.PartsUsage,
113113
)
114-
listCmd.Flags().StringVarP(&output, "output", "o", "table", pkg.TableUsage)
114+
listCmd.Flags().StringP("output", "o", "table", pkg.TableUsage)
115115
}
116116

117117
var listCmd = &cobra.Command{
@@ -120,6 +120,7 @@ var listCmd = &cobra.Command{
120120
Long: listLong,
121121
Example: listExample,
122122
Run: func(cmd *cobra.Command, args []string) {
123+
output, _ := cmd.Flags().GetString("output")
123124
input := channel.NewChannel(
124125
channel.WithCategoryId(categoryId),
125126
channel.WithForHandle(forHandle),

cmd/channel/update.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func init() {
7979
&description, "description", "d", "", descUsage,
8080
)
8181
updateCmd.Flags().StringVarP(&title, "title", "t", "", titleUsage)
82-
updateCmd.Flags().StringVarP(&output, "output", "o", "", pkg.SilentUsage)
82+
updateCmd.Flags().StringP("output", "o", "", pkg.SilentUsage)
8383

8484
_ = updateCmd.MarkFlagRequired("id")
8585
cmd.AddMutationFlags(updateCmd)
@@ -91,6 +91,7 @@ var updateCmd = &cobra.Command{
9191
Long: updateLong,
9292
Example: updateExample,
9393
Run: func(c *cobra.Command, args []string) {
94+
output, _ := c.Flags().GetString("output")
9495
err := cmd.Confirm(c, "Would update channel: %s", strings.Join(ids, ", "))
9596
if err != nil {
9697
utils.HandleCmdError(err, c)

cmd/channelBanner/channelBanner.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const (
1818
var (
1919
channelId string
2020
file string
21-
output string
2221

2322
onBehalfOfContentOwner string
2423
onBehalfOfContentOwnerChannel string

0 commit comments

Comments
 (0)