diff --git a/cmd/channel/channel.go b/cmd/channel/channel.go index b1a7d5e..9d446ff 100644 --- a/cmd/channel/channel.go +++ b/cmd/channel/channel.go @@ -18,10 +18,13 @@ var ( mySubscribers string onBehalfOfContentOwner string - title string - desc string - output string - parts []string + country string + customUrl string + defaultLanguage string + description string + title string + output string + parts []string ) var channelCmd = &cobra.Command{ diff --git a/cmd/channel/list.go b/cmd/channel/list.go index 486d396..3960a75 100644 --- a/cmd/channel/list.go +++ b/cmd/channel/list.go @@ -41,10 +41,10 @@ func init() { ) listCmd.Flags().StringVarP(&id, "id", "i", "", "Return the channels with the specified IDs") listCmd.Flags().StringVarP( - &managedByMe, "managedByMe", "m", "", "Specify the maximum number of items that should be returned", + &managedByMe, "managedByMe", "M", "", "Specify the maximum number of items that should be returned", ) - listCmd.Flags().Int64VarP(&maxResults, "maxResults", "N", 5, "The maximum number of items that should be returned") - listCmd.Flags().StringVarP(&mine, "mine", "n", "", "Return the ids of channels owned by the authenticated user") + listCmd.Flags().Int64VarP(&maxResults, "maxResults", "n", 5, "The maximum number of items that should be returned") + listCmd.Flags().StringVarP(&mine, "mine", "m", "", "Return the ids of channels owned by the authenticated user") listCmd.Flags().StringVarP( &mySubscribers, "mySubscribers", "s", "", "Return the channels subscribed to the authenticated user", ) diff --git a/cmd/channel/update.go b/cmd/channel/update.go index 47a9dbf..7efe63d 100644 --- a/cmd/channel/update.go +++ b/cmd/channel/update.go @@ -12,8 +12,11 @@ var updateCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { c := yutuber.NewChannel( yutuber.WithChannelId(id), + yutuber.WithChannelCountry(country), + yutuber.WithChannelCustomUrl(customUrl), + yutuber.WithChannelDefaultLanguage(defaultLanguage), + yutuber.WithChannelDescription(description), yutuber.WithChannelTitle(title), - yutuber.WithChannelDesc(desc), ) c.Update() }, @@ -23,8 +26,13 @@ func init() { channelCmd.AddCommand(updateCmd) updateCmd.Flags().StringVarP(&id, "id", "i", "", "ID of the channel") + updateCmd.Flags().StringVarP(&country, "country", "c", "", "Country of the channel") + updateCmd.Flags().StringVarP(&customUrl, "customUrl", "u", "", "Custom URL of the channel") + updateCmd.Flags().StringVarP( + &defaultLanguage, "defaultLanguage", "l", "", "The language of the channel's default title and description", + ) + updateCmd.Flags().StringVarP(&description, "description", "d", "", "Description of the channel") updateCmd.Flags().StringVarP(&title, "title", "t", "", "Title of the channel") - updateCmd.Flags().StringVarP(&desc, "desc", "d", "", "Description of the channel") updateCmd.MarkFlagRequired("id") } diff --git a/pkg/yutuber/channel.go b/pkg/yutuber/channel.go index 9d8c107..ec5533a 100644 --- a/pkg/yutuber/channel.go +++ b/pkg/yutuber/channel.go @@ -29,8 +29,11 @@ type channel struct { mySubscribers string onBehalfOfContentOwner string - title string - desc string + country string + customUrl string + defaultLanguage string + description string + title string } type Channel interface { @@ -124,12 +127,11 @@ func (c *channel) List(parts []string, output string) { func (c *channel) Update() { parts := []string{"snippet"} channel := c.get(parts)[0] - // TODO: is there a better way to check and update? if c.title != "" { channel.Snippet.Title = c.title } - if c.desc != "" { - channel.Snippet.Description = c.desc + if c.description != "" { + channel.Snippet.Description = c.description } call := service.Channels.Update(parts, channel) @@ -201,14 +203,32 @@ func WithChannelOnBehalfOfContentOwner(contentOwner string) ChannelOption { } } -func WithChannelTitle(title string) ChannelOption { +func WithChannelCountry(country string) ChannelOption { return func(c *channel) { - c.title = title + c.country = country + } +} + +func WithChannelCustomUrl(url string) ChannelOption { + return func(c *channel) { + c.customUrl = url + } +} + +func WithChannelDefaultLanguage(language string) ChannelOption { + return func(c *channel) { + c.defaultLanguage = language + } +} + +func WithChannelDescription(desc string) ChannelOption { + return func(c *channel) { + c.description = desc } } -func WithChannelDesc(desc string) ChannelOption { +func WithChannelTitle(title string) ChannelOption { return func(c *channel) { - c.desc = desc + c.title = title } }