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.

Offer peel leftovers with the app's place, not its name

Țugui Dragoș60e818819edb
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
index 8da91b4e..31328948 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
@@ -771,7 +771,8 @@ struct UninstallCommand: AsyncParsableCommand {
}
if plan.needsReview > 0 {
let them = plan.needsReview == 1 ? "it" : "them"
- notes.append("\(Output.count(plan.needsReview, "file needs", "files need")) review and will stay. See \(them) with `peel leftovers --all \(Output.lastArgument(app.name))`.")
+ let place = Output.quoted(Output.path(app.url))
+ notes.append("\(Output.count(plan.needsReview, "file needs", "files need")) review and will stay. See \(them) with `peel leftovers --all \(place)`.")
}
return notes
}
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index 790d492a..fab49340 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -61,12 +61,6 @@ enum Output {
return isPlain ? name : "'\(name.replacingOccurrences(of: "'", with: "'\\''"))'"
}
- /// Returns `name` as the last argument of a command to paste, quoted, and after `--` when it begins with `-`,
- /// which `peel` would otherwise read as options whatever the quotes.
- static func lastArgument(_ name: String) -> String {
- plain(name).hasPrefix("-") ? "-- " + quoted(name) : quoted(name)
- }
-
/// Writes `text` to standard output unchanged, for output that already ends in a newline. When the write fails
/// (a full disk, a closed stdout), the tool exits with status 1. `FileHandle.write(_:)` would instead raise an
/// exception Swift can't catch, and the tool would crash. A pipe whose reader has gone ends the process with
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
index 106c2b6a..f71ef4b5 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
@@ -665,10 +665,6 @@ struct CommandLineTests {
#expect(Output.quoted(name).hasPrefix("'"), "\(name) would break the command it is pasted into")
}
#expect(Output.quoted("Café-2.0_x86/64+@%:=,") == "Café-2.0_x86/64+@%:=,")
- #expect(Output.lastArgument("Editor") == "Editor")
- #expect(Output.lastArgument("Notes Pro") == "'Notes Pro'")
- #expect(Output.lastArgument("-Dash") == "-- -Dash")
- #expect(Output.lastArgument("-Dash Pro") == "-- '-Dash Pro'")
}
// MARK: peel uninstall
@@ -751,12 +747,12 @@ struct CommandLineTests {
#expect(notes[1] == "Peel couldn't look inside /Users/me/Library/Caches, so something may be there that isn't listed. Give your terminal app Full Disk Access in System Settings to read the folders macOS protects.")
#expect(notes[2].hasPrefix("There are more folders in /Users/me/Library/Caches than Peel looks inside"))
#expect(notes[3] == "1 item needs administrator access and will stay. Remove it with the Peel app.")
- #expect(notes[4] == "1 file needs review and will stay. See it with `peel leftovers --all Editor`.")
+ #expect(notes[4] == "1 file needs review and will stay. See it with `peel leftovers --all /Applications/Editor.app`.")
}
- @Test func offersACommandThatReadsANameBeginningWithADashAsTheApp() {
+ @Test func offersACommandThatNamesTheAppByItsPlaceSinceTwoAppsCanShareAName() {
let app = InstalledApp(
- url: URL(filePath: "/Applications/-Dash.app", directoryHint: .isDirectory),
+ url: URL(filePath: "/Applications/Beta Tools/-Dash.app", directoryHint: .isDirectory),
bundleIdentifier: "org.example.dash", name: "-Dash"
)
let review = leftover(URL(filePath: "/Users/me/Library/Caches/review"), heldBack: .namedLikeTheApp)
@@ -766,7 +762,7 @@ struct CommandLineTests {
plan, app: app, homebrew: CaskLookup.Answer(), scan: LeftoverScan(leftovers: [], unreadableLocations: [])
)
- #expect(notes == ["1 file needs review and will stay. See it with `peel leftovers --all -- -Dash`."])
+ #expect(notes == ["1 file needs review and will stay. See it with `peel leftovers --all '/Applications/Beta Tools/-Dash.app'`."])
}
@Test func saysWhereWhatOnlyAnAdministratorCanMoveIsListed() throws {
@@ -788,7 +784,7 @@ struct CommandLineTests {
)
#expect(notes == [
"1 item needs an administrator, and Peel's helper isn't allowed to move it. Once Editor is in the Trash, Orphaned Files in the Peel app lists it under Needs an Administrator, with how to remove it.",
- "1 file needs review and will stay. See it with `peel leftovers --all Editor`.",
+ "1 file needs review and will stay. See it with `peel leftovers --all /Applications/Editor.app`.",
])
#expect(UninstallPlan.make(editor, keepLeftovers: true, refusal: { _ in nil }).leftForAnAdministrator == 1)
let json = try Output.jsonText(