Solve the problem of removing an app before uninstalling it

Continuing the discussion from Uninstall & remove Apps:

I have just got out of a problem using this command. In case someone faces the same problem:

I ran bench rm app_name before running bench uninstall app_name; bench didn’t like that at all and it kept complaining about not being able to find the Module corresponding to that app_name. It turned out that a list of the installed apps is stored in the DB under tabDefaultValue table defkey ‘installed_apps’ and remove-from-installed-apps removed it from the list properly. Only then I can start using the site.

I think the logic behind this is overlooked due to updates and having things from the past kept around which make no sense.

It would make more sense to have bench rm app_name to run bench uninstall-app app_name before removing the app. Also, since uninstall-app does the proper thorough cleaning of the app references in the site, it would make sense to hook it up to remove the app from the list held by defkey in tabDefaultValue table as well. Dedicating a command just for the removal of the app from the tabDefaultValue is a waste of code.