tofuutils / tenv

OpenTofu / Terraform / Terragrunt and Atmos version manager
https://tofuutils.github.io/tenv/
Apache License 2.0
662 stars 32 forks source link

Add a "prune" command #181

Closed dvaumoron closed 2 months ago

dvaumoron commented 3 months ago

Is your feature request related to a problem? Please describe.

When you have installed a lot of version and need to remove most of them, it is pretty uncomfortable to do so one by one...

Describe the solution you'd like

I think a form of tenv <tool> prune with several kind of filter, a display of the list of version that will be uninstalled and a confirmation step would be great.

Anyone has suggestion about that proposal ?

Nmishin commented 3 months ago

sounds great!

kvendingoldo commented 3 months ago

Agree, that we need to have such command

kvendingoldo commented 3 months ago

But, started to think about it ... Maybe we can improve uninstall command instead of adding a new one?

Nmishin commented 3 months ago

yes, something like uninstall --all ?

dvaumoron commented 3 months ago

But, started to think about it ... Maybe we can improve uninstall command instead of adding a new one?

Yes, It could be done by improving the existing uninstall

dvaumoron commented 3 months ago

yes, something like uninstall --all ?

Should be part of the solution, however, that could be boring too, without auto installation (now disabled by default), you may have to launch a bunch of install command, hence the idea to filter and confirm (probably with version constraint, and maybe regexp, but i don't like the idea because constraint will be simpler to our user and there is no retrocompatibility need)

dvaumoron commented 3 months ago

I thought about storing last use date of each version to allow an uninstall based on version not used recently

kvendingoldo commented 3 months ago

I thought about storing last use date of each version to allow an uninstall based on version not used recently

It's a brilliant idea. I think, that we can show user the statistic and ask him about deletion of version that wasn't been in use for a long time.

samuel-phan commented 3 months ago

I think what suits most of users would be this:

1. Interactive uninstallation

Run without any version to uninstall => Text UI to select which versions to uninstall (with multi-selection)

tenv tf uninstall

Display text UI:

[ ] 1.0.0
[x] 1.2.3
[ ] 1.7.4
[x] 1.9.0

This UI can also be used for installation.

2. Uninstall all

Uninstall all versions of a given tool:

tenv tf uninstall --all

Uninstall all versions of all tools:

tenv uninstall --all

3. Uninstall based on different ways of selection

Uninstall all TF versions starting with 1.3. string:

tenv tf uninstall --regex ^1\.3\.

Uninstall all versions based on last usage (requires a tracking of last executed date time of a given version).

Uninstall all versions not used since a given date:

tenv tf uninstall --not-used-since=2024-06-30

Uninstall all versions not used for a given number of days:

tenv tf uninstall --not-used-for=30d

I don't recommend to use any other time unit than days (like months or years) because then you have to deal with calendar quirks (months with different number of days, etc.).

This uninstallation use case is already a corner case, so no need to invest too much in a master piece of engineering for 0.0001% of users.

dvaumoron commented 2 months ago

TODOs :

dvaumoron commented 2 months ago

v2.5.0 is out