@@ -9,13 +9,7 @@ import (
99)
1010
1111func init () {
12- // Parent command: themes
13- themesCmd .AddCommand (themesListCmd )
14- themesCmd .AddCommand (themesInfoCmd )
15- themesCmd .AddCommand (themesInstallCmd )
16- themesCmd .AddCommand (themesRemoveCmd )
17- themesCmd .AddCommand (themesUpdateCmd )
18- rootCmd .AddCommand (themesCmd )
12+ initThemesCmd ()
1913}
2014
2115var themesCmd = & cobra.Command {
@@ -80,6 +74,18 @@ var themesInstallCmd = &cobra.Command{
8074 Args : cobra .ExactArgs (1 ),
8175 RunE : func (cmd * cobra.Command , args []string ) error {
8276 identifier := args [0 ]
77+ // Check if not a URL and already installed
78+ if ! isURL (identifier ) {
79+ if existing := betterdiscord .FindAddon (betterdiscord .AddonTheme , identifier ); existing != nil {
80+ name := existing .Meta .Name
81+ if name == "" {
82+ name = existing .BaseName
83+ }
84+ output .Printf ("⚠️ Theme '%s' is already installed.\n " , name )
85+ output .Println ("💡 To update the theme, use: bdcli themes update <name|id|url>" )
86+ return nil
87+ }
88+ }
8389 resolved , err := betterdiscord .InstallAddon (betterdiscord .AddonTheme , identifier )
8490 if err != nil {
8591 return err
@@ -96,10 +102,20 @@ var themesRemoveCmd = &cobra.Command{
96102 Args : cobra .ExactArgs (1 ),
97103 RunE : func (cmd * cobra.Command , args []string ) error {
98104 identifier := args [0 ]
105+ // Check if addon exists before attempting removal
106+ existing := betterdiscord .FindAddon (betterdiscord .AddonTheme , identifier )
107+ if existing == nil {
108+ output .Printf ("❌ Theme '%s' is not installed.\n " , identifier )
109+ return nil
110+ }
99111 if err := betterdiscord .RemoveAddon (betterdiscord .AddonTheme , identifier ); err != nil {
100112 return err
101113 }
102- output .Printf ("✅ Theme removed: %s\n " , identifier )
114+ name := existing .Meta .Name
115+ if name == "" {
116+ name = existing .BaseName
117+ }
118+ output .Printf ("✅ Theme removed: %s\n " , name )
103119 return nil
104120 },
105121}
@@ -110,6 +126,50 @@ var themesUpdateCmd = &cobra.Command{
110126 Args : cobra .ExactArgs (1 ),
111127 RunE : func (cmd * cobra.Command , args []string ) error {
112128 identifier := args [0 ]
129+ checkOnly , _ := cmd .Flags ().GetBool ("check" )
130+
131+ // For non-URL identifiers, check if update is available
132+ if ! isURL (identifier ) {
133+ existing := betterdiscord .FindAddon (betterdiscord .AddonTheme , identifier )
134+ if existing == nil {
135+ output .Printf ("❌ Theme '%s' is not installed.\n " , identifier )
136+ return nil
137+ }
138+
139+ // Try to fetch from store to check version
140+ store , err := betterdiscord .FetchAddonFromStore (identifier )
141+ if err == nil && store != nil {
142+ localVersion := existing .Meta .Version
143+ storeVersion := store .Version
144+
145+ if localVersion == storeVersion {
146+ localName := existing .Meta .Name
147+ if localName == "" {
148+ localName = existing .BaseName
149+ }
150+ output .Printf ("✅ Theme '%s' is already up to date (v%s)\n " , localName , localVersion )
151+ return nil
152+ }
153+
154+ localName := existing .Meta .Name
155+ if localName == "" {
156+ localName = existing .BaseName
157+ }
158+
159+ if checkOnly {
160+ output .Printf ("📦 Update available for '%s'\n " , localName )
161+ output .Printf (" Current: v%s → Available: v%s\n " , localVersion , storeVersion )
162+ output .Println ("💡 To install the update, use: bdcli themes update <name|id|url> (without --check)" )
163+ return nil
164+ }
165+ }
166+ }
167+
168+ if checkOnly {
169+ output .Println ("⚠️ Cannot check version when using direct URL" )
170+ return nil
171+ }
172+
113173 resolved , err := betterdiscord .UpdateAddon (betterdiscord .AddonTheme , identifier )
114174 if err != nil {
115175 return err
@@ -118,3 +178,14 @@ var themesUpdateCmd = &cobra.Command{
118178 return nil
119179 },
120180}
181+
182+ func initThemesCmd () {
183+ // Parent command: themes
184+ themesCmd .AddCommand (themesListCmd )
185+ themesCmd .AddCommand (themesInfoCmd )
186+ themesCmd .AddCommand (themesInstallCmd )
187+ themesCmd .AddCommand (themesRemoveCmd )
188+ themesCmd .AddCommand (themesUpdateCmd )
189+ rootCmd .AddCommand (themesCmd )
190+ themesUpdateCmd .Flags ().BoolP ("check" , "c" , false , "Check for available updates without installing" )
191+ }
0 commit comments