@@ -124,10 +124,26 @@ var themesRemoveCmd = &cobra.Command{
124124var themesUpdateCmd = & cobra.Command {
125125 Use : "update <name|id|url>" ,
126126 Short : "Update a theme by name, ID, or URL" ,
127- Args : cobra .ExactArgs (1 ),
127+ Args : func (cmd * cobra.Command , args []string ) error {
128+ allFlag , _ := cmd .Flags ().GetBool ("all" )
129+ if allFlag {
130+ if len (args ) > 0 {
131+ return fmt .Errorf ("cannot specify addon identifier when using --all flag" )
132+ }
133+ return nil
134+ }
135+ return cobra .ExactArgs (1 )(cmd , args )
136+ },
128137 RunE : func (cmd * cobra.Command , args []string ) error {
129- identifier := args [0 ]
130138 checkOnly , _ := cmd .Flags ().GetBool ("check" )
139+ allFlag , _ := cmd .Flags ().GetBool ("all" )
140+
141+ // Handle --all flag
142+ if allFlag {
143+ return updateAllThemes (checkOnly )
144+ }
145+
146+ identifier := args [0 ]
131147
132148 // For non-URL identifiers, check if update is available
133149 if ! utils .IsURL (identifier ) {
@@ -180,6 +196,105 @@ var themesUpdateCmd = &cobra.Command{
180196 },
181197}
182198
199+ func updateAllThemes (checkOnly bool ) error {
200+ items , err := betterdiscord .ListAddons (betterdiscord .AddonTheme )
201+ if err != nil {
202+ return err
203+ }
204+
205+ if len (items ) == 0 {
206+ output .Println ("📭 No themes installed." )
207+ return nil
208+ }
209+
210+ var toUpdate []struct {
211+ entry betterdiscord.AddonEntry
212+ localVersion string
213+ storeVersion string
214+ name string
215+ }
216+
217+ output .Println ("🔍 Checking for theme updates..." )
218+
219+ // Check each theme for updates
220+ for _ , item := range items {
221+ name := item .Meta .Name
222+ if name == "" {
223+ name = item .BaseName
224+ }
225+
226+ // Try to find in store by name or ID
227+ identifier := name
228+ if identifier == "" {
229+ identifier = item .BaseName
230+ }
231+
232+ store , err := betterdiscord .FetchAddonFromStore (identifier )
233+ if err != nil {
234+ // Theme not in store, skip
235+ continue
236+ }
237+
238+ localVersion := item .Meta .Version
239+ storeVersion := store .Version
240+
241+ if localVersion != storeVersion {
242+ toUpdate = append (toUpdate , struct {
243+ entry betterdiscord.AddonEntry
244+ localVersion string
245+ storeVersion string
246+ name string
247+ }{
248+ entry : item ,
249+ localVersion : localVersion ,
250+ storeVersion : storeVersion ,
251+ name : name ,
252+ })
253+ }
254+ }
255+
256+ if len (toUpdate ) == 0 {
257+ output .Println ("✅ All themes are up to date!" )
258+ return nil
259+ }
260+
261+ output .Printf ("\n 📦 Found %d theme(s) with available updates:\n \n " , len (toUpdate ))
262+
263+ // Show what would be updated
264+ for _ , item := range toUpdate {
265+ output .Printf (" • %s: v%s → v%s\n " , item .name , item .localVersion , item .storeVersion )
266+ }
267+ output .Println ()
268+
269+ if checkOnly {
270+ output .Println ("💡 To install these updates, use: bdcli themes update --all (without --check)" )
271+ return nil
272+ }
273+
274+ // Perform updates
275+ updated := 0
276+ failed := 0
277+
278+ for _ , item := range toUpdate {
279+ identifier := item .name
280+ if identifier == "" {
281+ identifier = item .entry .BaseName
282+ }
283+
284+ _ , err := betterdiscord .UpdateAddon (betterdiscord .AddonTheme , identifier )
285+ if err != nil {
286+ output .Printf ("❌ Failed to update %s: %v\n " , item .name , err )
287+ failed ++
288+ } else {
289+ output .Printf ("✅ Updated %s to v%s\n " , item .name , item .storeVersion )
290+ updated ++
291+ }
292+ }
293+
294+ output .Printf ("\n 📊 Summary: %d updated, %d failed\n " , updated , failed )
295+ return nil
296+ }
297+
183298func initThemesCmd () {
184299 // Parent command: themes
185300 themesCmd .AddCommand (themesListCmd )
@@ -189,4 +304,5 @@ func initThemesCmd() {
189304 themesCmd .AddCommand (themesUpdateCmd )
190305 rootCmd .AddCommand (themesCmd )
191306 themesUpdateCmd .Flags ().BoolP ("check" , "c" , false , "Check for available updates without installing" )
192- }
307+ themesUpdateCmd .Flags ().BoolP ("all" , "a" , false , "Update all installed themes" )
308+ }
0 commit comments