From 7a79f3cec81be467f18f90b495a88648176f3e2e Mon Sep 17 00:00:00 2001 From: Alan Norton Date: Tue, 15 Oct 2024 15:25:59 -0400 Subject: [PATCH] install missing too ynot --- .../{asdf-prune-unused => asdf-sync-versions} | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) rename bin.Darwin/{asdf-prune-unused => asdf-sync-versions} (69%) diff --git a/bin.Darwin/asdf-prune-unused b/bin.Darwin/asdf-sync-versions similarity index 69% rename from bin.Darwin/asdf-prune-unused rename to bin.Darwin/asdf-sync-versions index 8ed9b9a..0ca1811 100755 --- a/bin.Darwin/asdf-prune-unused +++ b/bin.Darwin/asdf-sync-versions @@ -38,27 +38,41 @@ def get_in_use_versions_by_tool_name(): if __name__ == "__main__": in_use_map = get_in_use_versions_by_tool_name() - commands = [] + uninstall_commands = [] + install_missing_commands = [] for tool_name, versions in in_use_map.items(): print(f'Checking {tool_name}...') installed_versions = get_installed_versions(tool_name) + versions.sort() + installed_versions.sort() + print(f' In-Use: {", ".join(versions)}') print(f' Installed: {", ".join(installed_versions)}') unused = set(installed_versions) - set(versions) - print(f' Unused: {", ".join(unused)}') + missing = set(versions) - set(installed_versions) + print(f' Missing: {", ".join(missing)}') + for v in unused: - commands.append(f'asdf uninstall {tool_name} {v}') + uninstall_commands.append(f'asdf uninstall {tool_name} {v}') + + for v in missing: + install_missing_commands.append(f'asdf install {tool_name} {v}') + + if uninstall_commands: + response = input("🧹 Do you want to uninstall unused versions? (y/n): ").strip().lower() + if response in ['y', 'yes']: + for c in uninstall_commands: + print(f'> {c}') + subprocess.run(c, shell=True) - if commands: - response = input("🧹 Do you want to uninstall the unused versions? (y/n): ").strip().lower() + if install_missing_commands: + response = input("🔧 Do you want to install missing versions? (y/n): ").strip().lower() if response in ['y', 'yes']: - for c in commands: + for c in install_missing_commands: print(f'> {c}') subprocess.run(c, shell=True) - else: - print("✨ No unused versions to uninstall.")