| 80 | } |
| 81 | |
| 82 | func managedRecommendation(manager string, action string) string { |
| 83 | normalizedManager := strings.ToLower(strings.TrimSpace(manager)) |
| 84 | normalizedAction := strings.ToLower(strings.TrimSpace(action)) |
| 85 | if normalizedAction == "" { |
| 86 | normalizedAction = "change AGH" |
| 87 | } |
| 88 | |
| 89 | switch { |
| 90 | case strings.Contains(normalizedManager, "brew") || strings.Contains(normalizedManager, "homebrew"): |
| 91 | if strings.Contains(normalizedAction, lifecycleUninstallKey) { |
| 92 | return "Use `brew uninstall compozy/compozy/agh`." |
| 93 | } |
| 94 | return "Use `brew upgrade compozy/compozy/agh`." |
| 95 | case strings.Contains(normalizedManager, "npm") || |
| 96 | strings.Contains(normalizedManager, "node") || |
| 97 | strings.Contains(normalizedManager, "nodejs"): |
| 98 | if strings.Contains(normalizedAction, lifecycleUninstallKey) { |
| 99 | return "Use `npm uninstall -g @compozy/agh`." |
| 100 | } |
| 101 | return "Use `npm update -g @compozy/agh`." |
| 102 | case strings.Contains(normalizedManager, "scoop"): |
| 103 | if strings.Contains(normalizedAction, lifecycleUninstallKey) { |
| 104 | return "Use `scoop uninstall agh`." |
| 105 | } |
| 106 | return "Use `scoop update agh`." |
| 107 | case strings.Contains(normalizedManager, "nix"): |
| 108 | return "Update or remove AGH through your Nix configuration and run `nixos-rebuild switch`." |
| 109 | case strings.Contains(normalizedManager, "apt"), strings.Contains(normalizedManager, "deb"): |
| 110 | if strings.Contains(normalizedAction, lifecycleUninstallKey) { |
| 111 | return "Use `sudo apt remove agh` or the package name used to install AGH." |
| 112 | } |
| 113 | return "Use `sudo apt update && sudo apt upgrade agh` or the package name used to install AGH." |
| 114 | case strings.Contains(normalizedManager, "dnf"), strings.Contains(normalizedManager, "rpm"): |
| 115 | if strings.Contains(normalizedAction, lifecycleUninstallKey) { |
| 116 | return "Use `sudo dnf remove agh` or the package name used to install AGH." |
| 117 | } |
| 118 | return "Use `sudo dnf upgrade agh` or the package name used to install AGH." |
| 119 | default: |
| 120 | return "Use the package manager that set AGH_MANAGED instead of mutating this install directly." |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | func newUninstallCommand(deps commandDeps) *cobra.Command { |
| 125 | var ( |