Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Let This Belongs To name a command-line tool Homebrew installed

Țugui Dragoș0e612c280bda
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index b4b0375d..dd57af4b 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -403,7 +403,10 @@ macOS asks the user to approve it once. It talks to the app over XPC.
keeps a folder under its name; a name, remembered or learned, is compared without case, spaces, or punctuation
(`nameKey`). An app macOS knows on another disk that claims something is remembered too
(`OrphanScan.appsOnOtherDisks`, `Disks`), so its files stay its own while that disk isn't connected, and a link into
- an app on such a disk is not one into an app that is gone.
+ an app on such a disk is not one into an app that is gone. A group the person gave to an app or to a command-line
+ tool Homebrew installed (`OrphanOwner`) stays out while that app or tool is installed (`OrphanOwners.given`), the
+ tools read from the Cellar as Homebrew counts them (`Homebrew.installedFormulae`) right before each scan, in the app
+ and in `peel orphans` alike.
- **Intel Software.** `IntelInspector` judges by the code itself: what a bundle runs, or a file, is Intel only when
its Mach-O slices are x86_64 alone (`MachOHeader`), and a file found inside an app or beside a printer driver counts
only when it is a program (`MH_EXECUTE`), since a library runs in whatever loads it. It looks at the installed apps
@@ -511,7 +514,7 @@ where a Homebrew install takes them from.
| `~/Library/Application Support/Peel/digests.bin` | What Duplicates already read, so an unchanged file isn't read again. |
| `~/Library/Application Support/Peel/apps.json` | The apps Peel has seen, and those macOS knows on another disk that claimed a file, kept once they are gone or out of reach, so Orphaned Files can name what they left (`AppMemory`). |
| `~/Library/Application Support/Peel/teams.json` | Which team signs each app, so a change of signer can be told (`TeamRegistry`). |
-| `~/Library/Application Support/Peel/orphan-owners.json` | The orphaned files the user said belong to an installed app. |
+| `~/Library/Application Support/Peel/orphan-owners.json` | The orphaned files the user said belong to an app, or to a command-line tool Homebrew installed, by its formula (`OrphanOwner`). |
| `~/Library/Application Support/Peel/left-for-an-administrator.json` | What an uninstall left that only an administrator can move, from a place the helper doesn't serve, so Orphaned Files lists it under Needs an Administrator once the app is gone. |
| `~/Library/Application Support/Peel/dock-tiles.json` | The Dock icons an uninstall took out, and where each was, so History puts them back with their app. |
| `~/Library/Application Support/Peel/app-folders.json` | The folders the user chose for Peel to look for apps in, beside the Applications folders. |
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca3de3a4..52cdd8f4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,13 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
## 1.3.1 (not released yet)
+### Added
+
+#### Orphaned Files
+
+- This Belongs To… also offers the command-line tools Homebrew installed, so what a tool keeps under a dotted name
+ stays out of the list while that tool is installed. Settings > Exclusions shows the tool beside its group.
+
### Fixed
#### Orphaned Files
diff --git a/GUIDE.md b/GUIDE.md
index 25be0999..e6c03354 100644
--- a/GUIDE.md
+++ b/GUIDE.md
@@ -397,7 +397,8 @@ It sets up the command line as well:
page the folders named exactly with its identifier, such as its caches, and an update it downloaded; to keep its
other files, such as plug-ins or a folder named after it, exclude them too. Add them in
Settings > Exclusions, or Control-click a row and choose Exclude from Peel. In Orphaned Files, Control-click a
- group and choose This Belongs To…, and Peel stops listing it while the app you chose is installed.
+ group and choose This Belongs To…, and Peel stops listing it while the app, or the command-line tool from Homebrew,
+ you chose is installed.
## Work your way
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 9ab156b0..c2b991e4 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -35818,6 +35818,112 @@
}
}
},
+ "Command-Line Tools" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nástroje příkazového řádku"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Befehlszeilentools"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Herramientas de línea de comandos"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Outils de ligne de commande"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Strumenti da riga di comando"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "コマンドラインツール"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "명령어 라인 도구"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Commandoregeltools"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Narzędzia wiersza polecenia"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ferramentas de Linha de Comando"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Instrumente în linie de comandă"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Инструменты командной строки"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Kommandoradsverktyg"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Komut Satırı Araçları"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Інструменти командного рядка"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "命令行工具"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "命令列工具"
+ }
+ }
+ }
+ },
"Command-line tool" : {
"localizations" : {
"cs" : {
@@ -112559,108 +112665,108 @@
}
}
},
- "No orphaned files are said to belong to an app." : {
+ "No orphaned files are said to belong to an app or a tool." : {
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
- "value" : "U žádných osiřelých souborů jste zatím neuvedli, že patří některé aplikaci."
+ "value" : "U žádných osiřelých souborů jste zatím neuvedli, že patří některé aplikaci nebo některému nástroji."
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Für keine verwaisten Dateien wurde angegeben, dass sie zu einer App gehören."
+ "value" : "Für keine verwaisten Dateien wurde angegeben, dass sie zu einer App oder einem Befehlszeilentool gehören."
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
- "value" : "No has indicado que ningún archivo huérfano pertenezca a una app."
+ "value" : "No has indicado que ningún archivo huérfano pertenezca a una app ni a una herramienta."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Aucun fichier orphelin n’a été attribué à une app."
+ "value" : "Aucun fichier orphelin n’a été attribué à une app ou à un outil."
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Nessun file orfano è indicato come appartenente a un’app."
+ "value" : "Nessun file orfano è indicato come appartenente a un’app o a uno strumento."
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
- "value" : "アプリに属すると指定した孤立ファイルはありません。"
+ "value" : "アプリまたはコマンドラインツールに属すると指定した孤立ファイルはありません。"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
- "value" : "앱의 소유로 지정한 주인 없는 파일이 없습니다."
+ "value" : "앱 또는 명령어 라인 도구의 소유로 지정한 주인 없는 파일이 없습니다."
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Er zijn geen verweesde bestanden die volgens jou bij een app horen."
+ "value" : "Er zijn geen verweesde bestanden die volgens jou bij een app of een commandoregeltool horen."
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Nie wskazano żadnych osieroconych plików jako należących do aplikacji."
+ "value" : "Nie wskazano żadnych osieroconych plików jako należących do aplikacji lub narzędzia."
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Nenhum arquivo órfão foi indicado como pertencente a um app."
+ "value" : "Nenhum arquivo órfão foi indicado como pertencente a um app ou a uma ferramenta."
}
},
"ro" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Nu ați atribuit încă niciun fișier orfan unei aplicații."
+ "value" : "Nu ați atribuit încă niciun fișier orfan unei aplicații sau unui instrument."
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Нет осиротевших файлов, отмеченных как принадлежащие приложению."
+ "value" : "Нет осиротевших файлов, отмеченных как принадлежащие приложению или инструменту."
}
},
"sv" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Du har inte angett att några övergivna filer hör till en app."
+ "value" : "Du har inte angett att några övergivna filer hör till en app eller ett verktyg."
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Bir uygulamaya ait olduğunu söylediğiniz sahipsiz dosya yok."
+ "value" : "Bir uygulamaya veya araca ait olduğunu söylediğiniz sahipsiz dosya yok."
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Ви ще не вказали, що якісь покинуті файли належать програмі."
+ "value" : "Ви ще не вказали, що якісь покинуті файли належать програмі або інструменту."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "还没有被标为属于某个App的孤立文件。"
+ "value" : "还没有被标为属于某个App或命令行工具的孤立文件。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
- "value" : "你還沒有指定任何孤立檔案屬於某個App。"
+ "value" : "你還沒有指定任何孤立檔案屬於某個App或命令列工具。"
}
}
}
@@ -132999,214 +133105,214 @@
}
}
},
- "Orphaned Files That Belong to an App" : {
+ "Orphaned Files That Belong to an App or a Tool" : {
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Osiřelé soubory, které patří aplikaci"
+ "value" : "Osiřelé soubory, které patří aplikaci nebo nástroji"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Verwaiste Dateien, die zu einer App gehören"
+ "value" : "Verwaiste Dateien, die zu einer App oder einem Befehlszeilentool gehören"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Archivos huérfanos que pertenecen a una app"
+ "value" : "Archivos huérfanos que pertenecen a una app o a una herramienta"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Fichiers orphelins appartenant à une app"
+ "value" : "Fichiers orphelins appartenant à une app ou à un outil"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "File orfani che appartengono a un’app"
+ "value" : "File orfani che appartengono a un’app o a uno strumento"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
- "value" : "アプリに属する孤立ファイル"
+ "value" : "アプリまたはコマンドラインツールに属する孤立ファイル"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
- "value" : "앱의 소유로 지정한 주인 없는 파일"
+ "value" : "앱 또는 명령어 라인 도구의 소유로 지정한 주인 없는 파일"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Verweesde bestanden die bij een app horen"
+ "value" : "Verweesde bestanden die bij een app of een commandoregeltool horen"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Osierocone pliki należące do aplikacji"
+ "value" : "Osierocone pliki należące do aplikacji lub narzędzia"
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Arquivos Órfãos que Pertencem a um App"
+ "value" : "Arquivos Órfãos que Pertencem a um App ou a uma Ferramenta"
}
},
"ro" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Fișiere orfane care aparțin unei aplicații"
+ "value" : "Fișiere orfane care aparțin unei aplicații sau unui instrument"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Осиротевшие файлы, принадлежащие приложению"
+ "value" : "Осиротевшие файлы, принадлежащие приложению или инструменту"
}
},
"sv" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Övergivna filer som hör till en app"
+ "value" : "Övergivna filer som hör till en app eller ett verktyg"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Bir Uygulamaya Ait Sahipsiz Dosyalar"
+ "value" : "Bir Uygulamaya veya Araca Ait Sahipsiz Dosyalar"
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Покинуті файли, що належать програмі"
+ "value" : "Покинуті файли, що належать програмі або інструменту"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "属于某个App的孤立文件"
+ "value" : "属于某个App或命令行工具的孤立文件"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
- "value" : "屬於某個App的孤立檔案"
+ "value" : "屬於某個App或命令列工具的孤立檔案"
}
}
}
},
- "Orphaned Files doesn’t list these while the app you said they belong to is installed. Nothing of them was moved. Remove one to list it again." : {
+ "Orphaned Files doesn’t list these while the app or the command-line tool you said they belong to is installed. Nothing of them was moved. Remove one to list it again." : {
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Stránka Osiřelé soubory je nezobrazuje, dokud je nainstalovaná aplikace, o které jste uvedli, že jí patří. Nic z nich nebylo přesunuto. Chcete-li některou položku znovu zobrazit, odeberte ji."
+ "value" : "Stránka Osiřelé soubory je nezobrazuje, dokud je nainstalovaná aplikace nebo nástroj příkazového řádku, o kterých jste uvedli, že jim patří. Nic z nich nebylo přesunuto. Chcete-li některou položku znovu zobrazit, odeberte ji."
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Die Seite „Verwaiste Dateien“ zeigt diese nicht an, solange die App installiert ist, zu der sie laut deiner Angabe gehören. Nichts davon wurde verschoben. Entferne einen Eintrag, damit er dort wieder angezeigt wird."
+ "value" : "Die Seite „Verwaiste Dateien“ zeigt diese nicht an, solange die App oder das Befehlszeilentool installiert ist, zu der bzw. dem sie laut deiner Angabe gehören. Nichts davon wurde verschoben. Entferne einen Eintrag, damit er dort wieder angezeigt wird."
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
- "value" : "La página Archivos huérfanos no los muestra mientras esté instalada la app a la que has indicado que pertenecen. No se ha trasladado nada de ellos. Elimina uno para volver a mostrarlo."
+ "value" : "La página Archivos huérfanos no los muestra mientras esté instalada la app o la herramienta de línea de comandos a la que has indicado que pertenecen. No se ha trasladado nada de ellos. Elimina uno para volver a mostrarlo."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "La page Fichiers orphelins ne les liste pas tant que l’app à laquelle vous les avez attribués est installée. Aucun d’eux n’a été déplacé. Retirez-en un pour qu’il soit de nouveau listé."
+ "value" : "La page Fichiers orphelins ne les liste pas tant que l’app ou l’outil de ligne de commande auquel vous les avez attribués est installé. Aucun d’eux n’a été déplacé. Retirez-en un pour qu’il soit de nouveau listé."
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "“File orfani” non elenca questi file finché è installata l’app a cui hai detto che appartengono. Nessuno di questi è stato spostato. Rimuovine uno per elencarlo di nuovo."
+ "value" : "“File orfani” non elenca questi file finché è installata l’app o lo strumento da riga di comando a cui hai detto che appartengono. Nessuno di questi è stato spostato. Rimuovine uno per elencarlo di nuovo."
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
- "value" : "指定したアプリがインストールされている間は、“孤立ファイル”にこれらを表示しません。どの項目も移動していません。再び表示するには、リストから削除してください。"
+ "value" : "指定したアプリまたはコマンドラインツールがインストールされている間は、“孤立ファイル”にこれらを表示しません。どの項目も移動していません。再び表示するには、リストから削除してください。"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
- "value" : "주인 없는 파일 페이지는 소유 앱으로 지정한 앱이 설치되어 있는 동안 이 파일들을 나열하지 않습니다. 이 파일은 하나도 이동되지 않았습니다. 다시 나열하려면 목록에서 제거하십시오."
+ "value" : "주인 없는 파일 페이지는 소유자로 지정한 앱 또는 명령어 라인 도구가 설치되어 있는 동안 이 파일들을 나열하지 않습니다. 이 파일은 하나도 이동되지 않았습니다. 다시 나열하려면 목록에서 제거하십시오."
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "De pagina 'Verweesde bestanden' toont deze niet zolang de app waarbij ze volgens jou horen, geïnstalleerd is. Niets ervan is verplaatst. Verwijder er een om die weer te tonen."
+ "value" : "De pagina 'Verweesde bestanden' toont deze niet zolang de app of de commandoregeltool waarbij ze volgens jou horen, geïnstalleerd is. Niets ervan is verplaatst. Verwijder er een om die weer te tonen."
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Strona Osierocone pliki nie wyświetla ich, dopóki aplikacja, do której według Ciebie należą, jest zainstalowana. Nic z nich nie przeniesiono. Usuń pozycję, aby znów była wyświetlana."
+ "value" : "Strona Osierocone pliki nie wyświetla ich, dopóki aplikacja lub narzędzie wiersza polecenia, do których według Ciebie należą, jest zainstalowane. Nic z nich nie przeniesiono. Usuń pozycję, aby znów była wyświetlana."
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
- "value" : "A página Arquivos Órfãos não lista estes itens enquanto o app ao qual você disse que eles pertencem estiver instalado. Nenhum deles foi movido. Remova um para que ele volte a ser listado."
+ "value" : "A página Arquivos Órfãos não lista estes itens enquanto estiver instalado o app ou a ferramenta de linha de comando a que você disse que eles pertencem. Nenhum deles foi movido. Remova um para que ele volte a ser listado."
}
},
"ro" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Pagina Fișiere orfane nu le listează cât timp aplicația căreia ați spus că îi aparțin este instalată. Niciunul dintre fișiere nu a fost mutat. Eliminați un grup pentru a‑l lista din nou."
+ "value" : "Pagina Fișiere orfane nu le listează cât timp aplicația sau instrumentul în linie de comandă căruia ați spus că îi aparțin este instalat. Niciunul dintre fișiere nu a fost mutat. Eliminați un grup pentru a‑l lista din nou."
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Раздел «Осиротевшие файлы» не показывает эти файлы, пока установлено приложение, которому они, по Вашим словам, принадлежат. Ничего из них не перемещено. Уберите запись, и ее файлы снова появятся в списке."
+ "value" : "Раздел «Осиротевшие файлы» не показывает эти файлы, пока установлено приложение или инструмент командной строки, которому они, по Вашим словам, принадлежат. Ничего из них не перемещено. Уберите запись, и ее файлы снова появятся в списке."
}
},
"sv" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Sidan Övergivna filer visar inte de här så länge appen du angav att de hör till är installerad. Inget av dem har flyttats. Ta bort en för att visa den igen."
+ "value" : "Sidan Övergivna filer visar inte de här så länge appen eller kommandoradsverktyget du angav att de hör till är installerat. Inget av dem har flyttats. Ta bort en för att visa den igen."
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Sahipsiz Dosyalar, ait olduklarını söylediğiniz uygulama yüklü olduğu sürece bunları listelemez. Hiçbiri taşınmadı. Birini yeniden listelemek için onu kaldırın."
+ "value" : "Sahipsiz Dosyalar, ait olduklarını söylediğiniz uygulama veya komut satırı aracı yüklü olduğu sürece bunları listelemez. Hiçbiri taşınmadı. Birini yeniden listelemek için onu kaldırın."
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Розділ «Покинуті файли» не показує їх, поки інстальовано програму, якій вони, за вашими словами, належать. Нічого з них не переміщено. Вилучіть запис, щоб розділ знову його показував."
+ "value" : "Розділ «Покинуті файли» не показує їх, поки інстальовано програму або інструмент командного рядка, якому вони, за вашими словами, належать. Нічого з них не переміщено. Вилучіть запис, щоб розділ знову його показував."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "只要你指定它们所属的App仍已安装,“孤立文件”就不会列出这些项目。它们都没有被移动。移除其中一项即可再次列出它。"
+ "value" : "只要你指定它们所属的App或命令行工具仍已安装,“孤立文件”就不会列出这些项目。它们都没有被移动。移除其中一项即可再次列出它。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
- "value" : "只要你指定它們所屬的App仍已安裝,「孤立檔案」就不會列出它們。這些檔案都沒有被移動。移除其中一項,即可再次列出它。"
+ "value" : "只要你指定它們所屬的App或命令列工具仍已安裝,「孤立檔案」就不會列出它們。這些檔案都沒有被移動。移除其中一項,即可再次列出它。"
}
}
}
@@ -138553,108 +138659,108 @@
}
}
},
- "Peel can’t read its list of the orphaned files you said belong to an app, so it lists them all. Start the list over in Settings > Exclusions." : {
+ "Peel can’t read its list of the orphaned files you said belong to an app or a tool, so it lists them all. Start the list over in Settings > Exclusions." : {
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel nemůže přečíst svůj seznam osiřelých souborů, u kterých jste uvedli, že patří některé aplikaci, a proto je zobrazuje všechny. Začněte seznam znovu v Nastavení > Výjimky."
+ "value" : "Peel nemůže přečíst svůj seznam osiřelých souborů, u kterých jste uvedli, že patří některé aplikaci nebo některému nástroji, a proto je zobrazuje všechny. Začněte seznam znovu v Nastavení > Výjimky."
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel kann seine Liste der verwaisten Dateien, die laut deiner Angabe zu einer App gehören, nicht lesen, daher werden sie alle angezeigt. Beginne die Liste in den Einstellungen unter „Ausschlüsse“ neu."
+ "value" : "Peel kann seine Liste der verwaisten Dateien, die laut deiner Angabe zu einer App oder einem Befehlszeilentool gehören, nicht lesen, daher werden sie alle angezeigt. Beginne die Liste in den Einstellungen unter „Ausschlüsse“ neu."
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel no puede leer su lista de los archivos huérfanos que has indicado que pertenecen a una app, así que los muestra todos. Vuelve a empezar la lista en Ajustes > Exclusiones."
+ "value" : "Peel no puede leer su lista de los archivos huérfanos que has indicado que pertenecen a una app o a una herramienta, así que los muestra todos. Vuelve a empezar la lista en Ajustes > Exclusiones."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel ne peut pas lire sa liste des fichiers orphelins que vous avez attribués à une app : il les liste donc tous. Recommencez la liste dans Réglages > Exclusions."
+ "value" : "Peel ne peut pas lire sa liste des fichiers orphelins que vous avez attribués à une app ou à un outil : il les liste donc tous. Recommencez la liste dans Réglages > Exclusions."
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel non riesce a leggere il suo elenco dei file orfani che hai indicato come appartenenti a un’app, quindi li elenca tutti. Ricomincia l’elenco da capo in Impostazioni > Esclusioni."
+ "value" : "Peel non riesce a leggere il suo elenco dei file orfani che hai indicato come appartenenti a un’app o a uno strumento, quindi li elenca tutti. Ricomincia l’elenco da capo in Impostazioni > Esclusioni."
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peelは、アプリに属すると指定した孤立ファイルのリストを読み取れないため、それらをすべて表示します。“設定”>“除外”でリストを最初からやり直してください。"
+ "value" : "Peelは、アプリまたはコマンドラインツールに属すると指定した孤立ファイルのリストを読み取れないため、それらをすべて表示します。“設定”>“除外”でリストを最初からやり直してください。"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel이 앱의 소유로 지정한 주인 없는 파일 목록을 읽을 수 없으므로 해당 파일을 모두 나열합니다. 설정 > 제외 항목에서 목록을 처음부터 다시 시작하십시오."
+ "value" : "Peel이 앱 또는 명령어 라인 도구의 소유로 지정한 주인 없는 파일 목록을 읽을 수 없으므로 해당 파일을 모두 나열합니다. 설정 > 제외 항목에서 목록을 처음부터 다시 시작하십시오."
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel kan zijn lijst van verweesde bestanden die volgens jou bij een app horen, niet lezen, dus toont Peel ze allemaal. Begin in Instellingen > Uitsluitingen opnieuw met de lijst."
+ "value" : "Peel kan zijn lijst van verweesde bestanden die volgens jou bij een app of een commandoregeltool horen, niet lezen, dus toont Peel ze allemaal. Begin in Instellingen > Uitsluitingen opnieuw met de lijst."
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel nie może odczytać swojej listy osieroconych plików wskazanych przez Ciebie jako należące do aplikacji, więc wyświetla je wszystkie. Zacznij tę listę od nowa w Ustawieniach > Wykluczenia."
+ "value" : "Peel nie może odczytać swojej listy osieroconych plików wskazanych przez Ciebie jako należące do aplikacji lub narzędzia, więc wyświetla je wszystkie. Zacznij tę listę od nowa w Ustawieniach > Wykluczenia."
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
- "value" : "O Peel não consegue ler a lista dos arquivos órfãos que você indicou como pertencentes a um app, então lista todos eles. Recomece a lista em Ajustes > Exclusões."
+ "value" : "O Peel não consegue ler a lista dos arquivos órfãos que você indicou como pertencentes a um app ou a uma ferramenta, então lista todos eles. Recomece a lista em Ajustes > Exclusões."
}
},
"ro" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel nu își poate citi lista fișierelor orfane pe care le‑ați atribuit unei aplicații, așa că le listează pe toate. Reîncepeți lista în Configurări > Excluderi."
+ "value" : "Peel nu își poate citi lista fișierelor orfane pe care le‑ați atribuit unei aplicații sau unui instrument, așa că le listează pe toate. Reîncepeți lista în Configurări > Excluderi."
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel не удается прочитать свой список осиротевших файлов, которые Вы отметили как принадлежащие приложению, поэтому он показывает их все. Начните список заново в разделе «Настройки» > «Исключения»."
+ "value" : "Peel не удается прочитать свой список осиротевших файлов, которые Вы отметили как принадлежащие приложению или инструменту, поэтому он показывает их все. Начните список заново в разделе «Настройки» > «Исключения»."
}
},
"sv" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel kan inte läsa sin lista över de övergivna filer som du har angett hör till en app, så Peel listar dem alla. Börja om listan i Inställningar > Undantag."
+ "value" : "Peel kan inte läsa sin lista över de övergivna filer som du har angett hör till en app eller ett verktyg, så Peel listar dem alla. Börja om listan i Inställningar > Undantag."
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel, bir uygulamaya ait olduğunu söylediğiniz sahipsiz dosyalar listesini okuyamıyor, bu yüzden hepsini listeliyor. Listeyi Ayarlar > Hariç Tutulanlar’da baştan başlatın."
+ "value" : "Peel, bir uygulamaya veya araca ait olduğunu söylediğiniz sahipsiz dosyalar listesini okuyamıyor, bu yüzden hepsini listeliyor. Listeyi Ayarlar > Hariç Tutulanlar’da baştan başlatın."
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel не може прочитати свій список покинутих файлів, які, за вашими словами, належать програмі, тож показує їх усі. Почніть список наново в розділі Параметри > Винятки."
+ "value" : "Peel не може прочитати свій список покинутих файлів, які, за вашими словами, належать програмі або інструменту, тож показує їх усі. Почніть список наново в розділі Параметри > Винятки."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel无法读取你标为属于某个App的孤立文件的列表,因此会将它们全部列出。请在“设置”>“排除项”中重新开始建立该列表。"
+ "value" : "Peel无法读取你标为属于某个App或命令行工具的孤立文件的列表,因此会将它们全部列出。请在“设置”>“排除项”中重新开始建立该列表。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel無法讀取你指定屬於某個App的孤立檔案列表,因此會將它們全部列出。請在「設定」>「排除項目」中重新開始此列表。"
+ "value" : "Peel無法讀取你指定屬於某個App或命令列工具的孤立檔案列表,因此會將它們全部列出。請在「設定」>「排除項目」中重新開始此列表。"
}
}
}
@@ -178194,6 +178300,112 @@
}
}
},
+ "Search Apps and Tools" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Hledat v aplikacích a nástrojích"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Apps und Befehlszeilentools durchsuchen"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Buscar apps y herramientas"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Rechercher dans les apps et les outils"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Cerca app e strumenti"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "アプリとコマンドラインツールを検索"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "앱 및 명령어 라인 도구 검색"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Zoek in apps en commandoregeltools"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Szukaj aplikacji i narzędzi"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Buscar Apps e Ferramentas"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Căutare în aplicații și instrumente"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Поиск приложений и инструментов"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sök i appar och verktyg"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Uygulamalarda ve Araçlarda Ara"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Пошук програм та інструментів"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "搜索App和命令行工具"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "搜尋App和命令列工具"
+ }
+ }
+ }
+ },
"Search Background Items" : {
"localizations" : {
"cs" : {
@@ -193860,108 +194072,108 @@
}
}
},
- "Started the list of orphaned files that belong to an app over." : {
+ "Started the list of orphaned files that belong to an app or a tool over." : {
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Seznam osiřelých souborů, které patří aplikaci, byl začat znovu."
+ "value" : "Seznam osiřelých souborů, které patří aplikaci nebo nástroji, byl začat znovu."
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Die Liste der verwaisten Dateien, die zu einer App gehören, wurde neu begonnen."
+ "value" : "Die Liste der verwaisten Dateien, die zu einer App oder einem Befehlszeilentool gehören, wurde neu begonnen."
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Se ha vuelto a empezar la lista de archivos huérfanos que pertenecen a una app."
+ "value" : "Se ha vuelto a empezar la lista de archivos huérfanos que pertenecen a una app o a una herramienta."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "La liste des fichiers orphelins appartenant à une app a été recommencée."
+ "value" : "La liste des fichiers orphelins appartenant à une app ou à un outil a été recommencée."
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Ricominciato da capo l’elenco dei file orfani che appartengono a un’app."
+ "value" : "Ricominciato da capo l’elenco dei file orfani che appartengono a un’app o a uno strumento."
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
- "value" : "アプリに属する孤立ファイルのリストを最初からやり直しました。"
+ "value" : "アプリまたはコマンドラインツールに属する孤立ファイルのリストを最初からやり直しました。"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
- "value" : "앱의 소유로 지정한 주인 없는 파일 목록을 처음부터 다시 시작했습니다."
+ "value" : "앱 또는 명령어 라인 도구의 소유로 지정한 주인 없는 파일 목록을 처음부터 다시 시작했습니다."
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Opnieuw begonnen met de lijst van verweesde bestanden die bij een app horen."
+ "value" : "Opnieuw begonnen met de lijst van verweesde bestanden die bij een app of een commandoregeltool horen."
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Zaczęto od nowa listę osieroconych plików należących do aplikacji."
+ "value" : "Zaczęto od nowa listę osieroconych plików należących do aplikacji lub narzędzia."
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Lista de arquivos órfãos que pertencem a um app recomeçada."
+ "value" : "Lista de arquivos órfãos que pertencem a um app ou a uma ferramenta recomeçada."
}
},
"ro" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Lista fișierelor orfane care aparțin unei aplicații a fost reîncepută."
+ "value" : "Lista fișierelor orfane care aparțin unei aplicații sau unui instrument a fost reîncepută."
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Список осиротевших файлов, принадлежащих приложению, начат заново."
+ "value" : "Список осиротевших файлов, принадлежащих приложению или инструменту, начат заново."
}
},
"sv" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Började om listan över övergivna filer som hör till en app."
+ "value" : "Började om listan över övergivna filer som hör till en app eller ett verktyg."
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Bir uygulamaya ait sahipsiz dosyalar listesi baştan başlatıldı."
+ "value" : "Bir uygulamaya veya araca ait sahipsiz dosyalar listesi baştan başlatıldı."
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Список покинутих файлів, що належать програмі, почато наново."
+ "value" : "Список покинутих файлів, що належать програмі або інструменту, почато наново."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "已重新开始建立属于某个App的孤立文件列表。"
+ "value" : "已重新开始建立属于某个App或命令行工具的孤立文件列表。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
- "value" : "已重新開始屬於某個App的孤立檔案列表。"
+ "value" : "已重新開始屬於某個App或命令列工具的孤立檔案列表。"
}
}
}
@@ -216359,7 +216571,7 @@
"cs" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Patří aplikaci"
+ "value" : "Patří aplikaci nebo nástroji"
}
},
"de" : {
@@ -216389,13 +216601,13 @@
"ja" : {
"stringUnit" : {
"state" : "translated",
- "value" : "所属先のアプリ"
+ "value" : "所属先を指定"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
- "value" : "소유한 앱 지정"
+ "value" : "소유자 지정"
}
},
"nl" : {
@@ -216419,13 +216631,13 @@
"ro" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Aparține aplicației"
+ "value" : "Aparține aplicației sau instrumentului"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Принадлежит приложению"
+ "value" : "Принадлежит приложению или инструменту"
}
},
"sv" : {
@@ -216443,7 +216655,7 @@
"uk" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Належить програмі"
+ "value" : "Належить програмі або інструменту"
}
},
"zh-Hans" : {
@@ -216465,7 +216677,7 @@
"cs" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Patří aplikaci…"
+ "value" : "Patří aplikaci nebo nástroji…"
}
},
"de" : {
@@ -216495,13 +216707,13 @@
"ja" : {
"stringUnit" : {
"state" : "translated",
- "value" : "所属先のアプリ…"
+ "value" : "所属先を指定…"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
- "value" : "소유한 앱 지정…"
+ "value" : "소유자 지정…"
}
},
"nl" : {
@@ -216525,13 +216737,13 @@
"ro" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Aparține aplicației…"
+ "value" : "Aparține aplicației sau instrumentului…"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Принадлежит приложению…"
+ "value" : "Принадлежит приложению или инструменту…"
}
},
"sv" : {
@@ -216549,7 +216761,7 @@
"uk" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Належить програмі…"
+ "value" : "Належить програмі або інструменту…"
}
},
"zh-Hans" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
index 7aa14271..74460e35 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
@@ -108,12 +108,14 @@ struct OrphansCommand: AsyncParsableCommand {
let exclusions = await UnreadableExclusions.load()
let scanner = OrphanScanner(exclusions: exclusions)
let owners = OrphanOwners().load()
+ let formulae = await Homebrew.installedFormulae()
let scan = await ProgressLine.counting {
await scanner.scan(
installedApps: apps,
remembered: remembered,
running: running,
owners: owners ?? [:],
+ installedFormulae: formulae,
leftForAnAdministrator: await LeftForAnAdministrator().load()
)
}
@@ -147,16 +149,16 @@ struct OrphansCommand: AsyncParsableCommand {
}
}
- /// What the list could not cover, the groups the person said belong to an app when that list can't be read, the
- /// folders Peel could not read and the places with more folders inside than Peel looks into, and how to remove
- /// what only an administrator can move, with what a kernel extension needs: a restart, and on Apple silicon the
- /// startup disk's security set back.
+ /// What the list could not cover, the groups the person said belong to an app or a tool when that list can't be
+ /// read, the folders Peel could not read and the places with more folders inside than Peel looks into, and how to
+ /// remove what only an administrator can move, with what a kernel extension needs: a restart, and on Apple silicon
+ /// the startup disk's security set back.
static func notes(
for scan: OrphanScan, ownersUnreadable: Bool, onAppleSilicon: Bool = HostArchitecture.isAppleSilicon
) -> [String] {
var notes: [String] = []
if ownersUnreadable {
- notes.append("Peel can't read the list of orphaned files you said belong to an app, so it lists them too. Start the list over in Peel's Settings > Exclusions.")
+ notes.append("Peel can't read the list of orphaned files you said belong to an app or a command-line tool, so it lists them too. Start the list over in Peel's Settings > Exclusions.")
}
if !scan.unreadableLocations.isEmpty {
let folders = scan.unreadableLocations.map(\.url)
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
index e0f9b3bb..393d3007 100644
--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
@@ -905,6 +905,40 @@ public enum Homebrew {
try await installed().packages
}
+ /// The formulae installed, by name, as Homebrew counts them (`Formula.racks` in Homebrew 7's `formula.rb`): the
+ /// folders of its Cellar, not hidden and not links, that hold a folder. Empty where there is no Homebrew, and nil
+ /// where there is one Peel won't run or the Cellar can't be asked or listed: then they aren't known.
+ @concurrent
+ public static func installedFormulae(asking answers: Answers = Answers()) async -> Set<String>? {
+ guard executableURL != nil else { return refusedInAUsualPlace() == nil ? [] : nil }
+ guard let cellar = await answers.answer(["--cellar"]).flatMap(folder(answering:)) else { return nil }
+ return formulae(inCellar: cellar)
+ }
+
+ static func formulae(inCellar cellar: URL) -> Set<String>? {
+ let racks: [String]
+ do {
+ racks = try FileManager.default.contentsOfDirectory(atPath: cellar.path(percentEncoded: false))
+ } catch CocoaError.fileReadNoSuchFile {
+ return []
+ } catch {
+ return nil
+ }
+ return Set(racks.filter { name in
+ guard !name.hasPrefix(".") else { return false }
+ // Without the slash at its end, since `lstat` follows a link named with one.
+ let rack = cellar.appending(path: name, directoryHint: .notDirectory).path(percentEncoded: false)
+ var info = stat()
+ guard lstat(rack, &info) == 0, info.st_mode & S_IFMT == S_IFDIR,
+ let kegs = try? FileManager.default.contentsOfDirectory(atPath: rack)
+ else { return false }
+ var isFolder: ObjCBool = false
+ return kegs.contains { keg in
+ FileManager.default.fileExists(atPath: rack + "/" + keg, isDirectory: &isFolder) && isFolder.boolValue
+ }
+ })
+ }
+
/// The installed packages, each with what Homebrew's own settings make of it, and those settings, or nil when
/// Homebrew would not say them.
public static func installed(asking answers: Answers = Answers()) async throws(CommandFailure)
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift
index 623afda5..88bd632c 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift
@@ -121,11 +121,13 @@ public struct OrphanScan: Sendable {
keeping { $0.id != id }
}
- /// The same scan without the groups `owners` give to an app of `installedApps`, for a scan that ran while the
- /// person gave one away.
- public func leavingOut(given owners: [String: String], installedApps: [InstalledApp]) -> OrphanScan {
+ /// The same scan without the groups `owners` give to an app of `installedApps` or a formula of
+ /// `installedFormulae` (`OrphanOwners.given`), for a scan that ran while the person gave one away.
+ public func leavingOut(
+ given owners: [String: OrphanOwner], installedApps: [InstalledApp], installedFormulae: Set<String>?
+ ) -> OrphanScan {
let here = Set(installedApps.compactMap { $0.bundleIdentifier?.lowercased() })
- let given = Set(owners.filter { here.contains($0.value.lowercased()) }.keys.map { $0.lowercased() })
+ let given = OrphanOwners.given(owners, apps: here, formulae: installedFormulae)
return keeping { !OrphanScanner.isInAGroup($0.identifier, among: given) }
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanOwners.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanOwners.swift
index cbfffc4d..4892f3e0 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanOwners.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanOwners.swift
@@ -1,8 +1,43 @@
public import Foundation
internal import PeelPrivileged
-/// The orphaned files the person said belong to an installed app, by the identifier of their group, so Orphaned
-/// Files stops listing them while that app is installed. It only ever takes rows out of the list: nothing is moved.
+/// What a group of orphaned files belongs to, as the person said: an app, by its bundle identifier, or a command-line
+/// tool Homebrew installed, by the name of its formula.
+public enum OrphanOwner: Sendable, Hashable {
+ case app(String)
+ case formula(String)
+}
+
+extension OrphanOwner: Codable {
+ private enum CodingKeys: String, CodingKey {
+ case formula
+ }
+
+ /// An app is written as its bundle identifier alone, as every list written before tools could be named, and a
+ /// formula under its own key.
+ public init(from decoder: any Decoder) throws {
+ if let identifier = try? decoder.singleValueContainer().decode(String.self) {
+ self = .app(identifier)
+ } else {
+ self = .formula(try decoder.container(keyedBy: CodingKeys.self).decode(String.self, forKey: .formula))
+ }
+ }
+
+ public func encode(to encoder: any Encoder) throws {
+ switch self {
+ case .app(let identifier):
+ var container = encoder.singleValueContainer()
+ try container.encode(identifier)
+ case .formula(let name):
+ var container = encoder.container(keyedBy: CodingKeys.self)
+ try container.encode(name, forKey: .formula)
+ }
+ }
+}
+
+/// The orphaned files the person said belong to an app or a command-line tool, by the identifier of their group, so
+/// Orphaned Files stops listing them while that app or tool is installed. It only ever takes rows out of the list:
+/// nothing is moved.
public struct OrphanOwners: Sendable {
public let url: URL
@@ -14,9 +49,9 @@ public struct OrphanOwners: Sendable {
PeelFolder.url.appending(path: "orphan-owners.json")
}
- /// Each group's identifier, lowercased, and the bundle identifier of the app it belongs to: none while the file
- /// isn't there, and nil when it is there and can't be read, which lists those groups again.
- public func load() -> [String: String]? {
+ /// Each group's identifier, lowercased, and what it belongs to: none while the file isn't there, and nil when it is
+ /// there and can't be read, which lists those groups again.
+ public func load() -> [String: OrphanOwner]? {
// Taking the lock makes its file and folder, and a read must leave a home as it found it.
guard !url.isMissing else { return [:] }
return FileLock.whileHeld(beside: url) { read() }
@@ -38,17 +73,34 @@ public struct OrphanOwners: Sendable {
}
@discardableResult
- public func give(_ group: String, to bundleIdentifier: String) -> ListChange {
- change { $0[group.lowercased()] = bundleIdentifier }
+ public func give(_ group: String, to owner: OrphanOwner) -> ListChange {
+ change { $0[group.lowercased()] = owner }
}
- /// Forgets which app each of `groups` belongs to, so they are listed again.
+ /// Forgets what each of `groups` belongs to, so they are listed again.
@discardableResult
public func take(_ groups: [String]) -> ListChange {
change { owners in groups.forEach { owners[$0.lowercased()] = nil } }
}
- private func change(_ edit: (inout [String: String]) -> Void) -> ListChange {
+ /// The groups, lowercased, whose owner is on this Mac: an app among `apps`, the installed bundle identifiers, or a
+ /// formula among `formulae`, the installed ones. While the formulae aren't known, every group given to one stays
+ /// out, since the person's word stands until Peel knows better.
+ public static func given(
+ _ owners: [String: OrphanOwner], apps: Set<String>, formulae: Set<String>?
+ ) -> Set<String> {
+ Set(
+ owners.filter { _, owner in
+ switch owner {
+ case .app(let identifier): apps.contains(identifier.lowercased())
+ case .formula(let name): formulae?.contains(name) ?? true
+ }
+ }
+ .keys.map { $0.lowercased() }
+ )
+ }
+
+ private func change(_ edit: (inout [String: OrphanOwner]) -> Void) -> ListChange {
FileLock.whileHeld(beside: url) {
guard var owners = read() ?? (url.isMissing ? [:] : nil) else { return .notSaved(readProblem()) }
edit(&owners)
@@ -61,7 +113,7 @@ public struct OrphanOwners: Sendable {
}
}
- private func read() -> [String: String]? {
+ private func read() -> [String: OrphanOwner]? {
BoundedRead.data(at: url).flatMap(decoded)
}
@@ -71,7 +123,7 @@ public struct OrphanOwners: Sendable {
return decoded(data) == nil ? .damaged : nil
}
- private func decoded(_ data: Data) -> [String: String]? {
- try? JSONDecoder().decode([String: String].self, from: data)
+ private func decoded(_ data: Data) -> [String: OrphanOwner]? {
+ try? JSONDecoder().decode([String: OrphanOwner].self, from: data)
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
index a81b6659..1fc6c5d3 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
@@ -63,13 +63,15 @@ public struct OrphanScanner: Sendable {
/// `remembered` holds the apps Peel has seen installed before, so a group can be named after the app that
/// left it. `running` is what runs now, known by its bundle identifier: a helper or an agent can keep a
/// folder that no app bundle claims, and while it runs, its group is marked unsure. `owners` are the groups the
- /// person said belong to an app (`OrphanOwners`), left out while that app is installed.
+ /// person said belong to an app or a command-line tool (`OrphanOwners`), left out while that app is installed or
+ /// that tool is among `installedFormulae`, what Homebrew has installed, or while those aren't known (nil).
@concurrent
public func scan(
installedApps: [InstalledApp],
remembered: [RememberedApp] = [],
running: [RunningCopies.Process] = [],
- owners: [String: String] = [:],
+ owners: [String: OrphanOwner] = [:],
+ installedFormulae: Set<String>? = nil,
leftForAnAdministrator records: [LeftForAnAdministrator.Record] = []
) async -> OrphanScan {
let systemApps = if let systemApps { systemApps } else { await AppCatalog.systemApps.value }
@@ -179,7 +181,7 @@ public struct OrphanScanner: Sendable {
)
let folders = manifestFolders
let loadedByOtherApps = Plugins.LoadedByOtherApps(environment: environment)
- let given = Set(owners.filter { here.contains($0.value.lowercased()) }.keys.map { $0.lowercased() })
+ let given = OrphanOwners.given(owners, apps: here, formulae: installedFormulae)
let kept = found.compactMap { entry -> (identifier: String, item: OrphanItem, holds: Bool?)? in
guard !exclusions.excludes(entry.item.url), !exclusions.excludes(bundleIdentifier: entry.identifier),
!Self.isInAGroup(entry.identifier, among: given),
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift
index 604c32fd..cb569abb 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift
@@ -732,7 +732,7 @@ struct FileCommandTests {
])
#expect(OrphansCommand.notes(for: scan, ownersUnreadable: false) == [OrphansCommand.byHand])
#expect(OrphansCommand.notes(for: scan, ownersUnreadable: true).first?.hasPrefix(
- "Peel can't read the list of orphaned files you said belong to an app, so it lists them too."
+ "Peel can't read the list of orphaned files you said belong to an app or a command-line tool, so it lists them too."
) == true)
let json = try Output.jsonText(OrphansCommand.report(for: scan))
let report = try #require(JSONSerialization.jsonObject(with: Data(json.utf8)) as? [String: Any])
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
index 00c9f813..78720f77 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
@@ -22,6 +22,36 @@ struct HomebrewTests {
#expect(Homebrew.installation(versionAnswer: "Homebrew 7.0.9\n", prefixAnswer: "/p\n", cellarAnswer: "c\n") == nil)
}
+ @Test func countsAFormulaInstalledAsHomebrewDoes() throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("Cellar/exampletool/1.0/bin/exampletool")
+ try directory.file("Cellar/.hidden/1.0/bin/x")
+ try directory.directory("Cellar/emptied")
+ try directory.file("Cellar/stray")
+ try directory.file("elsewhere/rack/1.0/bin/x")
+ try directory.file("elsewhere/keg/bin/y")
+ let cellar = directory.url.appending(path: "Cellar", directoryHint: .isDirectory)
+ try FileManager.default.createSymbolicLink(
+ at: cellar.appending(path: "linked"), withDestinationURL: directory.url.appending(path: "elsewhere/rack")
+ )
+ try directory.directory("Cellar/kegged")
+ try FileManager.default.createSymbolicLink(
+ at: cellar.appending(path: "kegged/2.0"), withDestinationURL: directory.url.appending(path: "elsewhere/keg")
+ )
+
+ #expect(Homebrew.formulae(inCellar: cellar) == ["exampletool", "kegged"])
+ #expect(Homebrew.formulae(inCellar: directory.url.appending(path: "none", directoryHint: .isDirectory)) == [])
+ }
+
+ @Test(.permissionsHold) func formulaeAreNotKnownWhenTheCellarCannotBeListed() throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("Cellar/exampletool/1.0/bin/exampletool")
+ try directory.setPermissions(0, of: "Cellar")
+ defer { try? directory.setPermissions(0o755, of: "Cellar") }
+
+ #expect(Homebrew.formulae(inCellar: directory.url.appending(path: "Cellar", directoryHint: .isDirectory)) == nil)
+ }
+
@Test func aCommandForTerminalKeepsTheFormulaeTheExclusionsCover() {
#expect(Homebrew.terminalCommand("brew upgrade --cask example", keeping: []) == "brew upgrade --cask example")
#expect(
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanOwnersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanOwnersTests.swift
new file mode 100644
index 00000000..f8460f6f
--- /dev/null
+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanOwnersTests.swift
@@ -0,0 +1,42 @@
+import Foundation
+@testable import PeelCore
+import Testing
+
+struct OrphanOwnersTests {
+ @Test func readsAListWrittenBeforeAToolCouldBeNamed() throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("orphan-owners.json", contents: Data(#"{"org.example.helper":"com.installed.app"}"#.utf8))
+
+ let owners = OrphanOwners(url: directory.url.appending(path: "orphan-owners.json"))
+
+ #expect(owners.load() == ["org.example.helper": .app("com.installed.app")])
+ }
+
+ @Test func writesAnAppAsBeforeAndAToolUnderItsOwnKey() throws {
+ let directory = try TemporaryDirectory()
+ let url = directory.url.appending(path: "orphan-owners.json")
+ let owners = OrphanOwners(url: url)
+
+ #expect(owners.give("org.example.helper", to: .app("com.installed.app")) == .saved)
+ #expect(owners.give("org.example.tool", to: .formula("exampletool")) == .saved)
+
+ let written = try #require(try JSONSerialization.jsonObject(with: Data(contentsOf: url)) as? [String: Any])
+ #expect(written["org.example.helper"] as? String == "com.installed.app")
+ #expect(written["org.example.tool"] as? [String: String] == ["formula": "exampletool"])
+ }
+
+ @Test func leavesOutWhatBelongsToAnInstalledAppOrToolAndToAToolNotYetKnown() {
+ let owners: [String: OrphanOwner] = [
+ "org.example.given": .app("com.installed.app"), "org.example.gone": .app("org.example.notinstalled"),
+ "org.example.tool": .formula("exampletool"), "org.example.lost": .formula("gonetool"),
+ ]
+ let apps: Set<String> = ["com.installed.app"]
+
+ #expect(OrphanOwners.given(owners, apps: apps, formulae: ["exampletool"]) == ["org.example.given", "org.example.tool"])
+ #expect(OrphanOwners.given(owners, apps: apps, formulae: []) == ["org.example.given"])
+ #expect(
+ OrphanOwners.given(owners, apps: apps, formulae: nil)
+ == ["org.example.given", "org.example.tool", "org.example.lost"]
+ )
+ }
+}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
index 455476e4..cfa11507 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
@@ -131,7 +131,7 @@ struct OrphanScannerTests {
#expect(scan.groups.first?.rememberedApp?.bundleIdentifier == "md.example")
let given = await scanner(in: directory).scan(
- installedApps: installed, remembered: [gone], owners: ["md.example": "com.installed.app"]
+ installedApps: installed, remembered: [gone], owners: ["md.example": .app("com.installed.app")]
)
#expect(given.groups.isEmpty)
@@ -158,17 +158,39 @@ struct OrphanScannerTests {
requiresPrivileges: false
)
}
- let groups = ["org.example.given", "org.example.kept", "org.example.gone"].map {
+ let groups = ["org.example.given", "org.example.kept", "org.example.gone", "org.example.tool"].map {
OrphanGroup(identifier: $0, items: [item($0)])
}
let scan = OrphanScan(groups: groups, unreadableLocations: [])
+ let owners: [String: OrphanOwner] = [
+ "org.example.given": .app("com.installed.app"), "org.example.gone": .app("org.example.notinstalled"),
+ "org.example.tool": .formula("exampletool"),
+ ]
- let left = scan.leavingOut(
- given: ["org.example.given": "com.installed.app", "org.example.gone": "org.example.notinstalled"],
- installedApps: installed
- )
-
+ let left = scan.leavingOut(given: owners, installedApps: installed, installedFormulae: ["exampletool"])
#expect(left.groups.map(\.identifier) == ["org.example.kept", "org.example.gone"])
+
+ let toolGone = scan.leavingOut(given: owners, installedApps: installed, installedFormulae: [])
+ #expect(toolGone.groups.map(\.identifier) == ["org.example.kept", "org.example.gone", "org.example.tool"])
+
+ let toolsNotKnown = scan.leavingOut(given: owners, installedApps: installed, installedFormulae: nil)
+ #expect(toolsNotKnown.groups.map(\.identifier) == ["org.example.kept", "org.example.gone"])
+ }
+
+ @Test func aGroupThePersonGaveToAHomebrewToolIsNotListedWhileItIsInstalled() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("home/Library/Caches/org.example.tool/cache.db")
+ let scanner = scanner(in: directory)
+ let owners: [String: OrphanOwner] = ["org.example.tool": .formula("exampletool")]
+
+ let given = await scanner.scan(installedApps: installed, owners: owners, installedFormulae: ["exampletool"])
+ #expect(given.groups.isEmpty)
+
+ let toolGone = await scanner.scan(installedApps: installed, owners: owners, installedFormulae: [])
+ #expect(toolGone.groups.map(\.identifier) == ["org.example.tool"])
+
+ let toolsNotKnown = await scanner.scan(installedApps: installed, owners: owners, installedFormulae: nil)
+ #expect(toolsNotKnown.groups.isEmpty)
}
@Test func aTwoPartIdentifierNoAppDeclaredIsNeverAskedAboutAsAPrefix() {
@@ -826,10 +848,10 @@ struct OrphanScannerTests {
try directory.file("home/Library/Caches/org.example.other/cache.db")
let scanner = scanner(in: directory)
- let given = await scanner.scan(installedApps: installed, owners: ["org.example.helper": "com.installed.app"])
+ let given = await scanner.scan(installedApps: installed, owners: ["org.example.helper": .app("com.installed.app")])
#expect(given.groups.map(\.identifier) == ["org.example.other"])
- let ownerGone = await scanner.scan(installedApps: installed, owners: ["org.example.helper": "org.example.gone"])
+ let ownerGone = await scanner.scan(installedApps: installed, owners: ["org.example.helper": .app("org.example.gone")])
#expect(Set(ownerGone.groups.map(\.identifier)) == ["org.example.helper", "org.example.other"])
}
@@ -844,7 +866,7 @@ struct OrphanScannerTests {
#expect(listed.groups.map(\.identifier) == ["org.example.helper"])
#expect(listed.groups.first?.items.count == 3)
- let given = await scanner.scan(installedApps: installed, owners: ["org.example.helper": "com.installed.app"])
+ let given = await scanner.scan(installedApps: installed, owners: ["org.example.helper": .app("com.installed.app")])
#expect(given.groups.isEmpty)
}
@@ -869,12 +891,14 @@ struct OrphanScannerTests {
let owners = OrphanOwners(url: directory.url.appending(path: "orphan-owners.json"))
#expect(owners.load() == [:])
- #expect(owners.give("org.example.Helper", to: "com.installed.app") == .saved)
- #expect(owners.give("org.example.other", to: "com.microsoft.Word") == .saved)
- #expect(owners.load() == ["org.example.helper": "com.installed.app", "org.example.other": "com.microsoft.Word"])
+ #expect(owners.give("org.example.Helper", to: .app("com.installed.app")) == .saved)
+ #expect(owners.give("org.example.other", to: .formula("exampletool")) == .saved)
+ #expect(
+ owners.load() == ["org.example.helper": .app("com.installed.app"), "org.example.other": .formula("exampletool")]
+ )
#expect(owners.take(["org.example.helper"]) == .saved)
- #expect(owners.load() == ["org.example.other": "com.microsoft.Word"])
+ #expect(owners.load() == ["org.example.other": .formula("exampletool")])
}
@Test func aListOfOwnersIsReadWithoutWritingAndADamagedOneIsStartedOver() throws {
@@ -888,12 +912,12 @@ struct OrphanScannerTests {
try directory.file("Peel/orphan-owners.json", bytes: 16)
#expect(owners.load() == nil, "a list that can't be read read as no choices")
#expect(owners.whyUnreadable() == .damaged)
- #expect(owners.give("org.example.helper", to: "com.installed.app") == .notSaved(.damaged))
+ #expect(owners.give("org.example.helper", to: .app("com.installed.app")) == .notSaved(.damaged))
#expect(owners.startOver() == .started)
#expect(owners.load() == [:])
#expect(owners.whyUnreadable() == nil)
#expect(owners.startOver() == .notNeeded)
- #expect(owners.give("org.example.helper", to: "com.installed.app") == .saved)
+ #expect(owners.give("org.example.helper", to: .app("com.installed.app")) == .saved)
}
@Test(.permissionsHold) func saysWhyWhatBelongsToAnAppCouldNotBeSaved() throws {
@@ -904,7 +928,7 @@ struct OrphanScannerTests {
let refusedWrite = SystemError(domain: NSCocoaErrorDomain, code: NSFileWriteNoPermissionError)
let owners = OrphanOwners(url: folder.appending(path: "orphan-owners.json"))
- #expect(owners.give("org.example.helper", to: "com.installed.app") == .notSaved(.failed(refusedWrite)))
+ #expect(owners.give("org.example.helper", to: .app("com.installed.app")) == .notSaved(.failed(refusedWrite)))
}
/// An app installed since the scan owns what the list still calls orphaned.
diff --git a/Peel/Model/HomebrewLibrary.swift b/Peel/Model/HomebrewLibrary.swift
index 304eccb6..d9f6c0ba 100644
--- a/Peel/Model/HomebrewLibrary.swift
+++ b/Peel/Model/HomebrewLibrary.swift
@@ -83,6 +83,8 @@ final class HomebrewLibrary {
/// How the last reading failed, which is not the same as nothing being installed.
private(set) var couldNotRead: Homebrew.CommandFailure?
private(set) var packages: [HomebrewPackage]?
+ /// The command-line tools Homebrew installed: its formulae, none until the packages are read.
+ var formulae: [HomebrewPackage] { packages?.filter { $0.kind == .formula } ?? [] }
/// The installed Homebrew's version and prefix. The version decides what Peel may ask it for.
private(set) var installation: HomebrewInstallation?
/// What `brew cleanup` would free, as Homebrew reported it. Nil when it wouldn't say.
diff --git a/Peel/Model/OrphanLibrary.swift b/Peel/Model/OrphanLibrary.swift
index 582b5260..174ec178 100644
--- a/Peel/Model/OrphanLibrary.swift
+++ b/Peel/Model/OrphanLibrary.swift
@@ -20,9 +20,9 @@ final class OrphanLibrary {
/// The apps list the scan was checked against. The page scans again when the list changes.
private(set) var scannedAgainst: AppLibrary.Listing?
- /// The groups the person said belong to an app, by identifier, with that app's bundle identifier, or nil when that
- /// list can't be read.
- private(set) var owners: [String: String]?
+ /// The groups the person said belong to an app or a command-line tool, by identifier, or nil when that list can't
+ /// be read.
+ private(set) var owners: [String: OrphanOwner]?
/// Why that list can't be read, when Peel knows.
private(set) var whyOwnersUnreadable: FileProblem?
@@ -79,20 +79,25 @@ final class OrphanLibrary {
// What is currently running is better evidence than anything worked out from what is installed: a
// helper or an agent can keep a folder that no app bundle claims.
let running = RunningCopies.current
+ // Read right before the scan, so a group given to a tool follows the tool.
+ let formulae = await Homebrew.installedFormulae()
let scan = await OrphanScanner(exclusions: ExclusionsStore.shared.exclusions).scan(
installedApps: installedApps,
remembered: remembered,
running: running,
owners: owners ?? [:],
+ installedFormulae: formulae,
leftForAnAdministrator: await LeftForAnAdministrator().load()
)
if !scan.appsOnOtherDisks.isEmpty {
await AppMemory().remember(scan.appsOnOtherDisks)
}
- return scan
+ return (scan: scan, formulae: formulae)
}), library.readEverything else { return }
// The owners this scan began with may have grown while it ran.
- let result = found.leavingOut(given: self.owners ?? [:], installedApps: library.apps)
+ let result = found.scan.leavingOut(
+ given: self.owners ?? [:], installedApps: library.apps, installedFormulae: found.formulae
+ )
let remainingURLs = Set(result.groups.flatMap(\.items).filter { $0.leftAlone == nil }.map(\.url))
scan = result
scannedAgainst = listing
@@ -102,10 +107,10 @@ final class OrphanLibrary {
}
}
- /// Takes `group` out of the list, as the person said it belongs to `app`. Nothing moves, and the group stays
+ /// Takes `group` out of the list, as the person said it belongs to `owner`. Nothing moves, and the group stays
/// listed when the choice could not be saved.
- func give(_ group: OrphanGroup, to app: InstalledApp) -> ListChange {
- let change = app.bundleIdentifier.map { OrphanOwners().give(group.identifier, to: $0) } ?? .notSaved(nil)
+ func give(_ group: OrphanGroup, to owner: OrphanOwner) -> ListChange {
+ let change = OrphanOwners().give(group.identifier, to: owner)
readOwners()
guard change == .saved else { return change }
if let scan {
@@ -116,7 +121,7 @@ final class OrphanLibrary {
return .saved
}
- /// Lists `groups` again, forgetting the app each was given to.
+ /// Lists `groups` again, forgetting what each was given to.
func forget(_ groups: [String], from library: AppLibrary) async -> ListChange {
let change = OrphanOwners().take(groups)
guard change == .saved else {
diff --git a/Peel/Views/AppChooser.swift b/Peel/Views/AppChooser.swift
index 591511af..fc79450c 100644
--- a/Peel/Views/AppChooser.swift
+++ b/Peel/Views/AppChooser.swift
@@ -2,41 +2,109 @@ import AppKit
import PeelCore
import SwiftUI
-/// A short list of apps to choose one from, under a search field. A menu of every app would run to the screen's edge,
-/// and macOS gives a menu no shorter limit, so this list shows a few rows and scrolls past them.
+/// What a chooser offers: an app, or a command-line tool Homebrew installed.
+enum OwnerChoice: Identifiable, Hashable {
+ case app(InstalledApp)
+ case tool(HomebrewPackage)
+
+ enum ID: Hashable {
+ case app(InstalledApp.ID)
+ case tool(String)
+ }
+
+ var id: ID {
+ switch self {
+ case .app(let app): .app(app.id)
+ case .tool(let tool): .tool(tool.name)
+ }
+ }
+
+ var name: String {
+ switch self {
+ case .app(let app): app.name
+ case .tool(let tool): tool.name
+ }
+ }
+
+ /// What Orphaned Files keeps the choice as: an app by its bundle identifier, so nil for one without, and a tool by
+ /// its formula.
+ var owner: OrphanOwner? {
+ switch self {
+ case .app(let app): app.bundleIdentifier.map(OrphanOwner.app)
+ case .tool(let tool): .formula(tool.name)
+ }
+ }
+}
+
+/// A short list of apps, and of command-line tools when any are offered, to choose one from, under a search field. A
+/// menu of every app would run to the screen's edge, and macOS gives a menu no shorter limit, so this list shows a few
+/// rows and scrolls past them.
struct AppChooser: View {
private static let visibleRows = 8
private static let rowHeight: CGFloat = 28
+ private static let headingHeight: CGFloat = 22
@Environment(AppLibrary.self) private var library
- let apps: [InstalledApp]
- let choose: (InstalledApp) -> Void
+ private let apps: [InstalledApp]
+ private let tools: [HomebrewPackage]
+ private let choose: (OwnerChoice) -> Void
@State private var search = ""
- @State private var highlighted: InstalledApp.ID?
+ @State private var highlighted: OwnerChoice.ID?
+
+ init(apps: [InstalledApp], choose: @escaping (InstalledApp) -> Void) {
+ self.init(apps: apps, tools: []) { choice in
+ if case .app(let app) = choice { choose(app) }
+ }
+ }
- private var shown: [InstalledApp] {
+ init(apps: [InstalledApp], tools: [HomebrewPackage], choose: @escaping (OwnerChoice) -> Void) {
+ self.apps = apps
+ self.tools = tools
+ self.choose = choose
+ }
+
+ private var shownApps: [InstalledApp] {
apps.filter { AppListFilter.matches($0, text: search, developer: library.developer(of: $0)) }
.sorted { $0.name.localizedStandardCompare($1.name) == .orderedAscending }
}
+ private var shownTools: [HomebrewPackage] {
+ tools.filter { search.isEmpty || SearchText.matches($0.name, search) }
+ .sorted { $0.name.localizedStandardCompare($1.name) == .orderedAscending }
+ }
+
+ private var shown: [OwnerChoice] {
+ shownApps.map(OwnerChoice.app) + shownTools.map(OwnerChoice.tool)
+ }
+
var body: some View {
- let shown = shown
+ let apps = shownApps
+ let tools = shownTools
+ let shown = apps.map(OwnerChoice.app) + tools.map(OwnerChoice.tool)
+ // The two kinds get a heading each only while both are offered.
+ let headings = self.tools.isEmpty ? 0 : (apps.isEmpty ? 0 : 1) + (tools.isEmpty ? 0 : 1)
ScrollViewReader { proxy in
VStack(spacing: 8) {
- SearchBox(text: $search, prompt: String(localized: "Search Applications")) { step in
+ SearchBox(text: $search, prompt: prompt) { step in
highlighted = ListHighlight.moved(from: highlighted, by: step, among: shown.map(\.id))
if let highlighted { proxy.scrollTo(highlighted) }
} onReturn: {
- if let app = shown.first(where: { $0.id == highlighted }) { choose(app) }
+ if let choice = shown.first(where: { $0.id == highlighted }) { choose(choice) }
}
ScrollView {
LazyVStack(spacing: 0) {
- ForEach(shown) { row($0) }
+ if headings > 0, !apps.isEmpty { heading("Apps") }
+ ForEach(apps.map(OwnerChoice.app)) { row($0) }
+ if headings > 0, !tools.isEmpty { heading("Command-Line Tools") }
+ ForEach(tools.map(OwnerChoice.tool)) { row($0) }
}
}
.scrollBounceBehavior(.basedOnSize)
- .frame(height: CGFloat(min(max(shown.count, 1), Self.visibleRows)) * Self.rowHeight)
+ .frame(
+ height: CGFloat(min(max(shown.count, 1), Self.visibleRows)) * Self.rowHeight
+ + CGFloat(headings) * Self.headingHeight
+ )
.overlay {
if shown.isEmpty {
Text("No Results")
@@ -50,14 +118,33 @@ struct AppChooser: View {
}
}
- private func row(_ app: InstalledApp) -> some View {
+ private var prompt: String {
+ tools.isEmpty ? String(localized: "Search Applications") : String(localized: "Search Apps and Tools")
+ }
+
+ private func heading(_ title: LocalizedStringKey) -> some View {
+ Text(title)
+ .font(.caption.weight(.semibold))
+ .foregroundStyle(.secondary)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(.horizontal, 6)
+ .frame(height: Self.headingHeight)
+ }
+
+ private func row(_ choice: OwnerChoice) -> some View {
Button {
- choose(app)
+ choose(choice)
} label: {
HStack(spacing: 8) {
- AppIcon(url: app.url)
- .frame(width: 20, height: 20)
- Text(verbatim: app.name)
+ switch choice {
+ case .app(let app):
+ AppIcon(url: app.url)
+ .frame(width: 20, height: 20)
+ case .tool:
+ Image(systemName: "terminal")
+ .frame(width: 20, height: 20)
+ }
+ Text(verbatim: choice.name)
.lineLimit(1)
.truncationMode(.middle)
Spacer(minLength: 0)
@@ -67,9 +154,17 @@ struct AppChooser: View {
.contentShape(.rect)
}
.buttonStyle(.plain)
- .background(.quaternary.opacity(highlighted == app.id ? 1 : 0), in: .rect(cornerRadius: 6))
- .onHover { if $0 { highlighted = app.id } }
- .help(Text(verbatim: app.url.abbreviatedPath))
+ .background(.quaternary.opacity(highlighted == choice.id ? 1 : 0), in: .rect(cornerRadius: 6))
+ .onHover { if $0 { highlighted = choice.id } }
+ .help(Text(verbatim: help(for: choice)))
+ }
+
+ /// Where an app is, or what a tool does, as Homebrew says it.
+ private func help(for choice: OwnerChoice) -> String {
+ switch choice {
+ case .app(let app): app.url.abbreviatedPath
+ case .tool(let tool): tool.summary ?? tool.name
+ }
}
}
diff --git a/Peel/Views/Orphans/OrphanList.swift b/Peel/Views/Orphans/OrphanList.swift
index 11d456fe..bc255ef5 100644
--- a/Peel/Views/Orphans/OrphanList.swift
+++ b/Peel/Views/Orphans/OrphanList.swift
@@ -5,10 +5,11 @@ struct OrphanList: View {
@Environment(AppLibrary.self) private var library
@Environment(OrphanLibrary.self) private var orphans
@Environment(HelperModel.self) private var helper
+ @Environment(HomebrewLibrary.self) private var homebrew
@Environment(\.openSettings) private var openSettings
@State private var searchText = ""
@State private var isRescanning = false
- @State private var notGiven: (app: String, why: FileProblem?)?
+ @State private var notGiven: (name: String, why: FileProblem?)?
@State private var groupToGive: OrphanGroup?
var body: some View {
@@ -154,10 +155,13 @@ struct OrphanList: View {
.lineLimit(1)
.truncationMode(.middle)
}
- // What a group belongs to is kept by the app's identifier.
- AppChooser(apps: library.apps.filter { $0.bundleIdentifier != nil }) { app in
+ // What a group belongs to is kept by the app's identifier or the tool's formula.
+ AppChooser(
+ apps: library.apps.filter { $0.bundleIdentifier != nil }, tools: homebrew.formulae
+ ) { choice in
groupToGive = nil
- if case .notSaved(let why) = orphans.give(group, to: app) { notGiven = (app.name, why) }
+ guard let owner = choice.owner else { return }
+ if case .notSaved(let why) = orphans.give(group, to: owner) { notGiven = (choice.name, why) }
}
HStack {
Spacer()
@@ -169,7 +173,7 @@ struct OrphanList: View {
.padding(20)
}
.alert(
- "Peel couldn’t save that these files belong to \(notGiven?.app ?? "")",
+ "Peel couldn’t save that these files belong to \(notGiven?.name ?? "")",
isPresented: Binding(get: { notGiven != nil }, set: { if !$0 { notGiven = nil } })
) {
if orphans.owners == nil {
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index e196feff..33ac2335 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -313,10 +313,11 @@ extension AppLibrary {
}
extension OrphanLibrary {
- /// What an alert says when the list of orphaned files that belong to an app couldn't be changed, and why.
+ /// What an alert says when the list of orphaned files that belong to an app or a tool couldn't be changed, and
+ /// why.
func ownersNotSaved(_ why: FileProblem?) -> String {
let said = owners == nil
- ? String(localized: "Peel can’t read its list of the orphaned files you said belong to an app, so it lists them all. Start the list over in Settings > Exclusions.")
+ ? String(localized: "Peel can’t read its list of the orphaned files you said belong to an app or a tool, so it lists them all. Start the list over in Settings > Exclusions.")
: String(localized: "Nothing changed.")
return why.said(after: said, about: OrphanOwners.defaultURL)
}
diff --git a/Peel/Views/Settings/ExclusionsSettingsView.swift b/Peel/Views/Settings/ExclusionsSettingsView.swift
index 2278ef6e..7af2a991 100644
--- a/Peel/Views/Settings/ExclusionsSettingsView.swift
+++ b/Peel/Views/Settings/ExclusionsSettingsView.swift
@@ -185,7 +185,7 @@ struct ExclusionsSettingsView: View {
if let owners = orphans.owners {
let groups = owners.keys.sorted()
if groups.isEmpty {
- Text("No orphaned files are said to belong to an app.")
+ Text("No orphaned files are said to belong to an app or a tool.")
.foregroundStyle(.secondary)
} else {
List(selection: $selectedGroups) {
@@ -194,12 +194,23 @@ struct ExclusionsSettingsView: View {
Text(verbatim: group)
.lineLimit(1)
.truncationMode(.middle)
- if let owner = owners[group] {
- let name = library.apps.first { $0.bundleIdentifier == owner }?.name
- Text(verbatim: name ?? owner)
+ switch owners[group] {
+ case .app(let identifier)?:
+ let name = library.apps.first { $0.bundleIdentifier == identifier }?.name
+ Text(verbatim: name ?? identifier)
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(1)
+ case .formula(let name)?:
+ HStack(spacing: 4) {
+ Image(systemName: "terminal")
+ Text(verbatim: name)
+ .lineLimit(1)
+ }
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ case nil:
+ EmptyView()
}
}
.tag(group)
@@ -221,14 +232,14 @@ struct ExclusionsSettingsView: View {
Spacer(minLength: 8)
StartOverButton(
file: OrphanOwners.defaultURL,
- startedOver: "Started the list of orphaned files that belong to an app over."
+ startedOver: "Started the list of orphaned files that belong to an app or a tool over."
) {
orphans.startOwnersOver()
}
}
}
} header: {
- heading("Orphaned Files That Belong to an App", "Orphaned Files doesn’t list these while the app you said they belong to is installed. Nothing of them was moved. Remove one to list it again.")
+ heading("Orphaned Files That Belong to an App or a Tool", "Orphaned Files doesn’t list these while the app or the command-line tool you said they belong to is installed. Nothing of them was moved. Remove one to list it again.")
}
}
.formStyle(.grouped)