Skip to content

Commit

Permalink
install missing too ynot
Browse files Browse the repository at this point in the history
  • Loading branch information
nonrational committed Oct 15, 2024
1 parent a9c02eb commit 7a79f3c
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions bin.Darwin/asdf-prune-unused → bin.Darwin/asdf-sync-versions
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

0 comments on commit 7a79f3c

Please sign in to comment.