@@ -203,15 +203,28 @@ def update_cli():
203203
204204 if need_sudo :
205205 console .print ("[info]Permissions required to install to /usr/local/bin. Using sudo...[/info]" )
206+ if current_exe .exists ():
207+ subprocess .run (["sudo" , "mv" , str (current_exe ), f"{ current_exe } .old" ], check = False )
206208 subprocess .run (["sudo" , "mv" , str (temp_file ), str (current_exe )], check = True )
207209 subprocess .run (["sudo" , "chmod" , "+x" , str (current_exe )], check = True )
208210 else :
211+ if current_exe .exists ():
212+ old_exe = Path (f"{ current_exe } .old" )
213+ if old_exe .exists (): old_exe .unlink ()
214+ current_exe .rename (old_exe )
209215 current_exe .parent .mkdir (parents = True , exist_ok = True )
210216 shutil .move (str (temp_file ), str (current_exe ))
211217
212- console .print (f"[success]✔ Successfully updated to { latest_tag } ![/success]" )
218+ try :
219+ console .print (f"[success]✔ Successfully updated to { latest_tag } ![/success]" )
220+ except Exception :
221+ # Fallback to plain print if rich/PyInstaller fails to load modules after update
222+ print (f"Successfully updated to { latest_tag } !" )
213223
214224 except Exception as e :
215- console .print (f"[danger]✖ An error occurred during update: { e } [/danger]" )
225+ try :
226+ console .print (f"[danger]✖ An error occurred during update: { e } [/danger]" )
227+ except Exception :
228+ print (f"An error occurred during update: { e } " )
216229 if 'temp_file' in locals () and temp_file .exists ():
217230 temp_file .unlink ()
0 commit comments