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.

Say why each folder stays in peel projects --remove

Țugui Dragoș47b552e5be08
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
index 8d741ba9..f8e14e2c 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
@@ -668,8 +668,12 @@ struct ProjectsCommand: AsyncParsableCommand {
refusals: RefusalLog = RefusalLog()
) async throws {
let suggested = artifacts.filter(\.isRecommended)
+ let staying = artifacts.compactMap { artifact in
+ Self.reason(for: artifact).map { "\(Output.plain(Output.path(artifact.url))) stays: \($0)" }
+ }
guard !suggested.isEmpty else {
Output.line("Nothing here is safe to suggest. See `peel projects`.")
+ staying.forEach(Output.note)
return
}
let (source, sourceKey) = Self.source(of: suggested)
@@ -682,6 +686,7 @@ struct ProjectsCommand: AsyncParsableCommand {
)
try await cleanup.run(
question: "Move \(Output.count(cleanup.moving.count, "folder", "folders")) to the Trash?",
+ notes: staying,
dryRun: removal.dryRun,
yes: removal.yes,
using: service,
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift
index 8ed41b66..978de9e2 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift
@@ -184,16 +184,28 @@ struct FileCommandTests {
let fresh = try artifact("build", lastActivity: .now)
let developer = project.deletingLastPathComponent().path(percentEncoded: false)
- try await (command(["projects", developer, "--remove", "-y"]) as ProjectsCommand)
- .clean(
- [stale, fresh],
- using: try service(in: directory),
- recordingIn: logs.removals,
- refusals: logs.refusals
- )
+ let collected = Output.Collected()
+ try await Output.$collected.withValue(collected) {
+ try await (command(["projects", developer, "--remove", "-y"]) as ProjectsCommand)
+ .clean(
+ [stale, fresh],
+ using: try service(in: directory),
+ recordingIn: logs.removals,
+ refusals: logs.refusals
+ )
+ }
#expect(await moved(logs) == ["DerivedData"])
#expect(FileManager.default.fileExists(atPath: fresh.url.path(percentEncoded: false)))
+ #expect(collected.notes.contains("App/build stays: changed in the last 7 days"))
+
+ let onlyFresh = Output.Collected()
+ try await Output.$collected.withValue(onlyFresh) {
+ try await (command(["projects", developer, "--remove", "-y"]) as ProjectsCommand)
+ .clean([fresh], using: try service(in: directory), recordingIn: logs.removals, refusals: logs.refusals)
+ }
+ #expect(onlyFresh.output.contains("Nothing here is safe to suggest."))
+ #expect(onlyFresh.notes.contains("App/build stays: changed in the last 7 days"))
}
// MARK: Duplicates