Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
A cask that asks for an administrator's password is handed to Terminal
Țugui Dragoșd4d36d73d311
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex c523e8a7..3e252329 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -22818,6 +22818,218 @@}}},+ "Copy Uninstall Command" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Zkopírovat příkaz k odinstalaci"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Deinstallationsbefehl kopieren"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Copiar comando de desinstalación"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Copier la commande de désinstallation"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Copia comando di disinstallazione"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "アンインストールコマンドをコピー"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "제거 명령 복사"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kopieer de-installatiecommando"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kopiuj polecenie odinstalowania"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Copiar Comando de Desinstalação"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Copiați comanda de dezinstalare"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Скопировать команду удаления"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kopiera avinstallationskommando"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kaldırma Komutunu Kopyala"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Скопіювати команду деінсталювання"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "拷贝卸载命令"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "拷貝解除安裝指令"+ }+ }+ }+ },+ "Copy Upgrade Command" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Zkopírovat příkaz k upgradu"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Upgrade-Befehl kopieren"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Copiar comando de actualización"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Copier la commande de mise à niveau"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Copia comando di aggiornamento"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "アップグレードコマンドをコピー"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "업그레이드 명령 복사"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kopieer upgradecommando"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kopiuj polecenie uaktualnienia"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Copiar Comando de Upgrade"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Copiați comanda de upgrade"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Скопировать команду обновления"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kopiera uppgraderingskommando"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Yükseltme Komutunu Kopyala"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Скопіювати команду оновлення"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "拷贝升级命令"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "拷貝升級指令"+ }+ }+ }+ },"Critical" : {"localizations" : {"cs" : {@@ -39339,6 +39551,112 @@}}},+ "Homebrew needs an administrator’s password for this, and only Terminal can ask for it. Copy the command, then run it in Terminal." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew k tomu vyžaduje heslo správce, o které může požádat jen Terminál. Zkopírujte příkaz a pak ho spusťte v Terminálu."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew benötigt dafür das Passwort eines Administrators, und nur das Terminal kann es abfragen. Kopiere den Befehl und führe ihn dann im Terminal aus."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew necesita una contraseña de administrador para esto, y solo Terminal puede pedirla. Copia el comando y ejecútalo en Terminal."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew a besoin pour cela du mot de passe d’un administrateur, et seul Terminal peut le demander. Copiez la commande, puis exécutez-la dans Terminal."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Per questa operazione Homebrew ha bisogno della password di un amministratore, e solo Terminale può chiederla. Copia il comando, poi eseguilo in Terminale."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrewがこの操作を行うには管理者のパスワードが必要ですが、パスワードの入力を求めることができるのはターミナルだけです。コマンドをコピーしてターミナルで実行してください。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew는 이 작업에 관리자 암호가 필요하며, 암호는 터미널에서만 물을 수 있습니다. 명령을 복사한 다음 터미널에서 실행하십시오."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew heeft hiervoor een beheerderswachtwoord nodig, en alleen Terminal kan erom vragen. Kopieer het commando en voer het daarna uit in Terminal."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew potrzebuje do tego hasła administratora, a poprosić o nie może tylko Terminal. Skopiuj polecenie, a potem uruchom je w Terminalu."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O Homebrew precisa da senha de um administrador para isso, e só o Terminal pode pedi-la. Copie o comando e execute-o no Terminal."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Pentru aceasta, Homebrew are nevoie de parola unui administrator, pe care doar Terminal o poate cere. Copiați comanda, apoi rulați‑o în Terminal."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Для этого Homebrew нужен пароль администратора, а запросить его может только Терминал. Скопируйте команду и выполните ее в Терминале."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew behöver en administratörs lösenord för det här, och bara Terminal kan be om det. Kopiera kommandot och kör det sedan i Terminal."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew’un bunun için bir yönetici parolasına ihtiyacı var ve parolayı yalnızca Terminal isteyebilir. Komutu kopyalayın, ardından Terminal’de çalıştırın."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew потребує для цього пароля адміністратора, а попросити його може лише Термінал. Скопіюйте команду, а потім виконайте її в Терміналі."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew执行此操作需要管理员密码,而只有“终端”能要求你输入该密码。请拷贝该命令,然后在“终端”中运行。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew需要管理者密碼才能執行此操作,而只有「終端機」能要求輸入密碼。請拷貝指令,然後在「終端機」中執行。"+ }+ }+ }+ },"Homebrew no longer lists this package." : {"localizations" : {"cs" : {@@ -57846,6 +58164,112 @@}}},+ "Needs Terminal" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Vyžaduje Terminál"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Benötigt Terminal"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Necesita Terminal"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nécessite Terminal"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Richiede Terminale"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "ターミナルが必要"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "터미널 필요"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Terminal vereist"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Wymaga Terminala"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Requer o Terminal"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Necesită Terminal"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Нужен Терминал"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kräver Terminal"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Terminal gerekli"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Потрібен Термінал"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "需要终端"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "需要終端機"+ }+ }+ }+ },"Needs administrator access" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swiftindex 2ffb80b8..87890991 100644--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift@@ -37,12 +37,25 @@ public struct HomebrewPackage: Sendable, Hashable, Identifiable {public let emptyFolderPatterns: [String]/// Set when Homebrew has deprecated or disabled the package.public let retirement: HomebrewRetirement?+ /// True for a cask whose upgrade runs a step as root with `sudo`, which asks for a password that only a+ /// terminal can give: an installer package, an installer script run with `sudo`, or an `uninstall` step that+ /// needs one, since an upgrade removes the old version first.+ public let upgradeNeedsAnAdministrator: Bool+ /// True for a cask whose `uninstall` stanza runs a step with `sudo`: `pkgutil`, `delete`, `kext`, or a script+ /// run with `sudo`.+ public let uninstallNeedsAnAdministrator: Bool/// The entries of `packageIdentifiers` whose receipts are installed, lowercased. `noting(receipts:)` sets/// them, so the cask carries this proof to every place that checks it.public private(set) var receiptsOnThisMac: [String] = []public var id: String { "\(kind.rawValue)/\(name)" }+ /// Whether Upgrade All takes it along when it is out of date: a pinned package is held at its version on purpose,+ /// and a cask whose upgrade needs an administrator is upgraded in Terminal.+ public var joinsUpgradeAll: Bool {+ !isPinned && !upgradeNeedsAnAdministrator+ }+/// Returns a copy that notes which `packageIdentifiers` are among `receipts`, the lowercased identifiers of/// the installed receipts. A pattern such as `com.adobe.acrobat.DC.*` matches none and proves nothing,/// which errs on the safe side.@@ -71,7 +84,9 @@ public struct HomebrewPackage: Sendable, Hashable, Identifiable {emptyFolderPatterns: [String] = [],quitIdentifiers: [String] = [],packageIdentifiers: [String] = [],- retirement: HomebrewRetirement? = nil+ retirement: HomebrewRetirement? = nil,+ upgradeNeedsAnAdministrator: Bool = false,+ uninstallNeedsAnAdministrator: Bool = false) {self.name = nameself.kind = kind@@ -92,6 +107,8 @@ public struct HomebrewPackage: Sendable, Hashable, Identifiable {self.quitIdentifiers = quitIdentifiersself.packageIdentifiers = packageIdentifiersself.retirement = retirement+ self.upgradeNeedsAnAdministrator = upgradeNeedsAnAdministrator+ self.uninstallNeedsAnAdministrator = uninstallNeedsAnAdministrator}}@@ -213,8 +230,14 @@ struct CaskArtifact: Decodable, Sendable {let quitIdentifiers: [String]/// Installer receipts the cask forgets, which can be matched against the receipts on this Mac.let packageIdentifiers: [String]+ /// True when installing runs as root: an installer package, or an installer script run with `sudo`.+ let installNeedsAnAdministrator: Bool+ /// True when the `uninstall` stanza runs a step as root: `pkgutil`, `delete` and `kext` always do, and a+ /// script when it says `sudo`. `launchctl` tries with `sudo` and goes on without it, and `zap` is not run.+ let uninstallNeedsAnAdministrator: Boolprivate static let removalKeys = ["trash", "delete"]+ private static let stepsRunAsRoot = ["pkgutil", "delete", "kext"]init(from decoder: any Decoder) throws {let container = try decoder.singleValueContainer()@@ -248,6 +271,12 @@ struct CaskArtifact: Decodable, Sendable {emptyFolderPatterns = emptyFoldersquitIdentifiers = quitspackageIdentifiers = packages++ let runsAsRoot = { (script: CaskValue?) in (script?.dictionaries ?? []).contains { $0["sudo"]?.isTrue == true } }+ installNeedsAnAdministrator = raw["pkg"] != nil || (raw["installer"]?.dictionaries ?? []).contains { runsAsRoot($0["script"]) }+ uninstallNeedsAnAdministrator = (raw["uninstall"]?.dictionaries ?? []).contains { stanza in+ Self.stepsRunAsRoot.contains { stanza[$0] != nil } || runsAsRoot(stanza["script"]) || runsAsRoot(stanza["early_script"])+ }}}@@ -256,6 +285,7 @@ indirect enum CaskValue: Decodable, Sendable {case string(String)case list([CaskValue])case dictionary([String: CaskValue])+ case boolean(Bool)case otherinit(from decoder: any Decoder) throws {@@ -266,6 +296,8 @@ indirect enum CaskValue: Decodable, Sendable {self = .list(value)} else if let value = try? container.decode([String: CaskValue].self) {self = .dictionary(value)+ } else if let value = try? container.decode(Bool.self) {+ self = .boolean(value)} else {self = .other}@@ -275,7 +307,7 @@ indirect enum CaskValue: Decodable, Sendable {switch self {case .string(let value): [value]case .list(let values): values.flatMap(\.strings)- case .dictionary, .other: []+ case .dictionary, .boolean, .other: []}}@@ -283,9 +315,13 @@ indirect enum CaskValue: Decodable, Sendable {switch self {case .dictionary(let value): [value]case .list(let values): values.flatMap(\.dictionaries)- case .string, .other: []+ case .string, .boolean, .other: []}}++ var isTrue: Bool {+ if case .boolean(true) = self { true } else { false }+ }}public enum Homebrew {@@ -533,7 +569,9 @@ public enum Homebrew {emptyFolderPatterns: cask.artifacts?.flatMap(\.emptyFolderPatterns) ?? [],quitIdentifiers: cask.artifacts?.flatMap(\.quitIdentifiers) ?? [],packageIdentifiers: cask.artifacts?.flatMap(\.packageIdentifiers) ?? [],- retirement: cask.retirement.value+ retirement: cask.retirement.value,+ upgradeNeedsAnAdministrator: cask.artifacts?.contains { $0.installNeedsAnAdministrator || $0.uninstallNeedsAnAdministrator } ?? false,+ uninstallNeedsAnAdministrator: cask.artifacts?.contains(where: \.uninstallNeedsAnAdministrator) ?? false)}return (formulae + casks).sorted { $0.name.localizedStandardCompare($1.name) == .orderedAscending }diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swiftindex eb0fac4a..009acb35 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift@@ -100,6 +100,44 @@ struct HomebrewTests {#expect(packages.first { $0.name == "other" }?.isPinned == false)}+ /// Homebrew runs some steps of a cask as root with `sudo`, which asks for a password only a terminal can give+ /// (`cask/artifact/pkg.rb` and `abstract_uninstall.rb`, 7.0.4). The artifacts are written as `brew info+ /// --json=v2` writes Zoom's, Adobe AIR's, and a plain app's.+ @Test func knowsWhichCasksNeedAnAdministrator() throws {+ let json = """+ {+ "formulae": [],+ "casks": [+ {"token": "meeting", "installed": "6.0", "version": "6.1", "outdated": true, "artifacts": [+ {"uninstall": [{"launchctl": ["org.example.meeting.updater"], "pkgutil": "org.example.meeting.pkg",+ "delete": ["/Library/Internet Plug-Ins/Meeting.plugin"]}]},+ {"pkg": ["MeetingInstaller.pkg"]}]},+ {"token": "runtime", "installed": "51.1", "version": "51.2", "outdated": true, "artifacts": [+ {"uninstall": [{"script": {"executable": "Runtime Installer.app/Contents/MacOS/Runtime Installer",+ "args": ["-uninstall"], "sudo": true}, "rmdir": ["/Applications/Runtime"]}]},+ {"installer": [{"script": {"executable": "Runtime Installer.app/Contents/MacOS/Runtime Installer",+ "args": ["-silent"], "sudo": true}}]}]},+ {"token": "player", "installed": "3.0", "version": "3.0", "outdated": false, "artifacts": [+ {"app": ["Player.app"]},+ {"uninstall": [{"launchctl": "org.example.player.helper", "quit": "org.example.player"}]},+ {"zap": [{"trash": ["~/Library/Application Support/Player"], "delete": "/Library/Player"}]}]},+ {"token": "helper", "installed": "1.0", "version": "1.1", "outdated": true, "artifacts": [+ {"installer": [{"script": {"executable": "Install Helper", "sudo": false}}]},+ {"uninstall": [{"kext": "org.example.helper.driver"}]}]}+ ]+ }+ """+ let packages = try #require(Homebrew.parseInstalled(Data(json.utf8)))+ let needs = { (name: String) in+ packages.first { $0.name == name }.map { [$0.upgradeNeedsAnAdministrator, $0.uninstallNeedsAnAdministrator] }+ }++ #expect(needs("meeting") == [true, true], "an installer package and `pkgutil` both run with sudo")+ #expect(needs("runtime") == [true, true], "scripts run with sudo")+ #expect(needs("player") == [false, false], "launchctl goes on without sudo, and zap is not what uninstalling runs")+ #expect(needs("helper") == [true, true], "a kernel extension is unloaded with sudo, when upgrading too")+ }+/// The JSON follows what Homebrew 7.0.4 reports for packages it has stopped or will stop offering. A package/// can be deprecated and disabled at once (disabled wins), a deprecated one carries the day it will be/// disabled, and a reason is one of Homebrew's keywords or a sentence a maintainer wrote.diff --git a/Peel/Model/HomebrewLibrary.swift b/Peel/Model/HomebrewLibrary.swiftindex cce0f36a..cd846490 100644--- a/Peel/Model/HomebrewLibrary.swift+++ b/Peel/Model/HomebrewLibrary.swift@@ -94,9 +94,9 @@ final class HomebrewLibrary {return retired.filter { $0.retirement?.stage == .disabled } + retired.filter { $0.retirement?.stage == .deprecated }}- /// A pinned package is held at its version on purpose, so it is shown as out of date and left alone.+ /// What Upgrade All upgrades: the rest are shown as out of date and left alone (`joinsUpgradeAll`).var upgradable: [HomebrewPackage] {- outdated.filter { !$0.isPinned }+ outdated.filter(\.joinsUpgradeAll)}func count(of kind: HomebrewPackage.Kind) -> Int {diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swiftindex c79efe6a..c65ec781 100644--- a/Peel/Views/AppDetailView.swift+++ b/Peel/Views/AppDetailView.swift@@ -414,11 +414,18 @@ struct AppDetailView: View {private func updateExplanation(for source: UpdateSource) -> LocalizedStringResource {switch source {case .appStore: "The App Store has it. Update from the App Store."+ case .homebrew where upgradeNeedsTerminal:+ "Homebrew needs an administrator’s password for this, and only Terminal can ask for it. Copy the command, then run it in Terminal."case .homebrew: "Homebrew has it. Peel can run the upgrade for you."case .developer, .automatic: "The maker has it. Update from inside the app."}}+ /// Whether the cask asks for an administrator's password when it upgrades, which only Terminal can give.+ private var upgradeNeedsTerminal: Bool {+ library.cask(for: plan.app)?.upgradeNeedsAnAdministrator == true+ }+@ViewBuilderprivate func updateAction(for source: UpdateSource, version: String) -> some View {switch source {@@ -428,6 +435,10 @@ struct AppDetailView: View {NSWorkspace.shared.open(page ?? URL(string: "macappstore://showUpdatesPage")!)}.buttonStyle(.borderedProminent)+ case .homebrew where upgradeNeedsTerminal:+ if let cask = library.cask(for: plan.app) {+ CopyButton(text: "brew upgrade --cask \(cask.fullName)", title: "Copy Upgrade Command")+ }case .homebrew:Button {Task { await upgradeWithHomebrew() }diff --git a/Peel/Views/Homebrew/HomebrewDetailView.swift b/Peel/Views/Homebrew/HomebrewDetailView.swiftindex d63b557e..d27602bd 100644--- a/Peel/Views/Homebrew/HomebrewDetailView.swift+++ b/Peel/Views/Homebrew/HomebrewDetailView.swift@@ -85,11 +85,15 @@ struct HomebrewDetailView: View {Section {HStack {if package.isOutdated {- Button("Upgrade", systemImage: "arrow.down.circle") {- Task { await homebrew.run(.upgrade(package.id)) }+ if package.upgradeNeedsAnAdministrator {+ CopyButton(text: "brew upgrade --cask \(package.fullName)", title: "Copy Upgrade Command")+ } else {+ Button("Upgrade", systemImage: "arrow.down.circle") {+ Task { await homebrew.run(.upgrade(package.id)) }+ }+ .buttonStyle(.borderedProminent)+ .disabled(package.isPinned)}- .buttonStyle(.borderedProminent)- .disabled(package.isPinned)}if isRunning {ProgressView()@@ -101,12 +105,21 @@ struct HomebrewDetailView: View {.foregroundStyle(.secondary)}Spacer()- Button("Uninstall", systemImage: "trash", role: .destructive) {- isConfirmingUninstall = true+ if isUninstalledInTerminal {+ CopyButton(text: "brew uninstall --cask \(package.fullName)", title: "Copy Uninstall Command")+ } else {+ Button("Uninstall", systemImage: "trash", role: .destructive) {+ isConfirmingUninstall = true+ }+ .disabled(uninstallRefusal != nil)}- .disabled(uninstallRefusal != nil)}.disabled(homebrew.runningCommand != nil)+ if (package.isOutdated && package.upgradeNeedsAnAdministrator) || isUninstalledInTerminal {+ Text(needsTerminal)+ .font(.callout)+ .foregroundStyle(.secondary)+ }}}.formStyle(.grouped)@@ -124,6 +137,15 @@ struct HomebrewDetailView: View {}}+ /// Said where Peel hands a cask's command to Terminal: `brew` asks for an administrator's password with `sudo`,+ /// which needs a terminal, and Peel runs it without one.+ private let needsTerminal: LocalizedStringResource = "Homebrew needs an administrator’s password for this, and only Terminal can ask for it. Copy the command, then run it in Terminal."++ /// A cask whose uninstall needs an administrator is offered as a command, unless it may not be uninstalled at all.+ private var isUninstalledInTerminal: Bool {+ package.uninstallNeedsAnAdministrator && uninstallRefusal == nil+ }+/// Why Uninstall is unavailable, or nil when it's allowed. `brew uninstall` deletes permanently, outside/// `TrashService` and `RemovalGuard`, so this is where the exclusions are checked.private var uninstallRefusal: LocalizedStringResource? {@@ -136,8 +158,7 @@ struct HomebrewDetailView: View {private var isRunning: Bool {switch homebrew.runningCommand {case .upgrade(let id), .uninstall(let id): id == package.id- // Upgrade All upgrades this package too if it's outdated and not pinned.- case .upgradeAll: package.isOutdated && !package.isPinned+ case .upgradeAll: package.isOutdated && package.joinsUpgradeAllcase .update, .cleanup, .health, .vulnerabilities, nil: false}}diff --git a/Peel/Views/Homebrew/HomebrewList.swift b/Peel/Views/Homebrew/HomebrewList.swiftindex 956010d7..22866f94 100644--- a/Peel/Views/Homebrew/HomebrewList.swift+++ b/Peel/Views/Homebrew/HomebrewList.swift@@ -292,6 +292,8 @@ struct HomebrewList: View {Spacer(minLength: 4)if package.isPinned {Badge(title: Text("Pinned"), systemImage: "pin", tint: .secondary)+ } else if package.upgradeNeedsAnAdministrator {+ Badge(title: Text("Needs Terminal"), systemImage: "terminal", tint: .secondary)}}.padding(.vertical, 2)@@ -311,7 +313,7 @@ struct HomebrewList: View {.minimumTarget()}.buttonStyle(.borderless)- .disabled(outdated.allSatisfy(\.isPinned) || isBusy)+ .disabled(!outdated.contains(where: \.joinsUpgradeAll) || isBusy)}}}diff --git a/README.md b/README.mdindex 06c78f2c..1ed4d926 100644--- a/README.md+++ b/README.md@@ -119,7 +119,7 @@ lists them.- **Package Receipts:** what installer packages put on your Mac, item by item.- **Intel Software:** everything that still needs Rosetta, including helpers hidden inside universal apps.- **Homebrew:** your formulae and casks, with Update, Clean Up, Check Health, Scan for Vulnerabilities, Upgrade,- and Uninstall.+ and Uninstall, or the command to run in Terminal for a cask that asks for an administrator's password.### Fine-tune your Mac