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
peel caches refuses a tool name that matches nothing
Țugui Dragoșf6eeda266fb8
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swiftindex 3f33d2e3..0b138b36 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift@@ -244,16 +244,19 @@ struct CachesCommand: AsyncParsableCommand {}/// Returns the environments named in `tools`, by the name the listing shows or by its identifier, ignoring- /// case. All of them when `tools` is empty.+ /// case. All of them when `tools` is empty. A name that matches none fails the command, even beside one that+ /// matches: shown the rest, a typo would read as a tool with nothing to show.static func chosen(from environments: [DeveloperEnvironment], named tools: [String]) throws -> [DeveloperEnvironment] {guard !tools.isEmpty else { return environments }- let chosen = environments.filter { environment in- tools.contains { $0.caseInsensitiveCompare(environment.name) == .orderedSame || $0.caseInsensitiveCompare(environment.id) == .orderedSame }+ func isNamed(_ environment: DeveloperEnvironment, _ tool: String) -> Bool {+ [environment.name, environment.id].contains { tool.caseInsensitiveCompare($0) == .orderedSame }}- guard !chosen.isEmpty else {- throw CommandFailure("No developer caches of \(tools.map(Output.quoted).joined(separator: ", ")) were found. See `peel caches`.")+ let unmatched = tools.filter { tool in !environments.contains { isNamed($0, tool) } }+ guard unmatched.isEmpty else {+ let names = unmatched.map(Output.quoted).joined(separator: ", ")+ throw CommandFailure("No developer caches of \(names) were found. See `peel caches`.")}- return chosen+ return environments.filter { environment in tools.contains { isNamed(environment, $0) } }}func clean(diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swiftindex 58bb4750..bb65c8c5 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift@@ -64,6 +64,12 @@ struct FileCommandTests {#expect(try CachesCommand.chosen(from: [brew, cargo], named: ["RUST"]).map(\.id) == ["rust"])#expect(try CachesCommand.chosen(from: [brew, cargo], named: ["Homebrew", "Rust"]).count == 2)#expect(throws: CommandFailure.self) { try CachesCommand.chosen(from: [brew, cargo], named: ["Nonesuch"]) }+ // A name that matches nothing beside one that does is a typo, never a tool with nothing to show.+ let typo = #expect(throws: CommandFailure.self) {+ try CachesCommand.chosen(from: [brew, cargo], named: ["rust", "hombrew"])+ }+ let hombrew = Output.quoted("hombrew")+ #expect(typo?.description == "No developer caches of \(hombrew) were found. See `peel caches`.")}/// Model weights and installed packages are listed and never suggested, so `--remove` leaves them.