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
Give each tool's identifier in peel caches
Țugui Dragoș4b416526cbef
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swiftindex 64082746..b1b622ed 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift@@ -324,6 +324,7 @@ struct CachesCommand: AsyncParsableCommand {struct Record: Encodable {let tool: String+ let id: Stringlet size: MeasuredSizelet locations: [Location]@@ -375,13 +376,20 @@ struct CachesCommand: AsyncParsableCommand {Output.line("No developer caches found.")} else {for environment in environments {- Output.line("\(environment.name) \(Output.size(environment.total))")+ Output.line("\(Self.title(of: environment, among: environments)) \(Output.size(environment.total))")Output.table(Self.rows(for: environment), indent: " ")}}Self.notes(for: environments).forEach(Output.note)}+ /// A tool's name, as `peel caches <tool>` takes it. Electron apps are named for the app, so two can share a name,+ /// and then each gets its identifier beside it.+ static func title(of environment: DeveloperEnvironment, among environments: [DeveloperEnvironment]) -> String {+ let isShared = environments.contains { $0.name == environment.name && $0.id != environment.id }+ return isShared ? "\(environment.name) (\(environment.id))" : environment.name+ }+static func rows(for environment: DeveloperEnvironment) -> [[String]] {environment.locations.map { [Output.size($0.size), Output.path($0.url), $0.kind.summary, note(for: $0)] }}@@ -429,17 +437,20 @@ struct CachesCommand: AsyncParsableCommand {static func records(for environments: [DeveloperEnvironment]) -> [Record] {environments.map { environment in- Record(tool: environment.name, size: MeasuredSize(environment.total), locations: environment.locations.map {- Record.Location(- path: Output.path($0.url),- size: MeasuredSize($0.size),- kind: $0.kind.rawValue,- source: $0.source,- suggested: $0.isRecommended,- heldBack: heldBack(of: $0),- reason: reason(for: $0)- )- })+ Record(+ tool: environment.name, id: environment.id, size: MeasuredSize(environment.total),+ locations: environment.locations.map {+ Record.Location(+ path: Output.path($0.url),+ size: MeasuredSize($0.size),+ kind: $0.kind.rawValue,+ source: $0.source,+ suggested: $0.isRecommended,+ heldBack: heldBack(of: $0),+ reason: reason(for: $0)+ )+ }+ )}}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swiftindex d6306fa9..66b58c67 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift@@ -899,6 +899,20 @@ struct FileCommandTests {#expect(locations[1]["suggested"] as? Bool == false)}+ @Test func namesEachToolSoACommandCanAskForItAlone() throws {+ let directory = try TemporaryDirectory()+ let one = try environment("Chat", id: "electron.org.example.one", locations: [("Library/one", .cache)], in: directory)+ let two = try environment("Chat", id: "electron.org.example.two", locations: [("Library/two", .cache)], in: directory)+ let rust = try environment("Rust", id: "rust", locations: [("Library/Caches/cargo", .cache)], in: directory)++ let json = try Output.jsonText(CachesCommand.records(for: [one, two, rust]))++ let records = try #require(JSONSerialization.jsonObject(with: Data(json.utf8)) as? [[String: Any]])+ #expect(records.map { $0["id"] as? String } == ["electron.org.example.one", "electron.org.example.two", "rust"])+ #expect(CachesCommand.title(of: one, among: [one, two, rust]) == "Chat (electron.org.example.one)")+ #expect(CachesCommand.title(of: rust, among: [one, two, rust]) == "Rust")+ }+/// A script reading `peel caches --json` gets, for each folder, where its tool documents it.@Test func tellsWhereEachCacheIsDocumented() throws {let directory = try TemporaryDirectory()