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 that peel's JSON keeps a name whole

Țugui Dragoș3f4256a671ad
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index db95b984..a27e343f 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -463,7 +463,8 @@ each item, stop there with `--dry-run`, ask unless given `-y`, exit 2 when the a
couldn't finish, and write the same History the app shows. The tool never uses the helper. Everything it prints goes
through `Output`, so scripts can read it: its own words are plain ASCII, and names, paths, and what macOS says in an
error are printed as they are, in UTF-8, with every character that could hide or reorder text shown as `?`
-(`PlainText`). A long scan says how far it has got on one line of standard error, written over itself and cleared
+(`PlainText`). JSON keeps each value whole, by JSON's own rules, since a script needs the real name. A long scan says
+how far it has got on one line of standard error, written over itself and cleared
before anything else is printed (`ProgressLine`). Only a terminal shows it, and only while `peel` is its foreground
job, so a script reading standard error gets nothing.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
index eb44c6b8..332489f3 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
@@ -544,6 +544,13 @@ struct CommandLineTests {
== "No leftovers Peel suggests. 11 files need review. Add --all to see them.")
}
+ @Test func textHidesWhatCouldReorderANameAndJSONKeepsItWhole() throws {
+ let name = "Notes\u{202E}.app"
+
+ #expect(Output.plain(name) == "Notes?.app")
+ #expect(try Output.jsonText(["name": name]).contains(name))
+ }
+
@Test func withoutASubcommandItShowsTheHelpAndFails() async throws {
let command = try #require(try PeelCommand.parseAsRoot([]) as? PeelCommand)
let collected = Output.Collected()
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
index f76457b1..5f9df7b1 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
@@ -55,6 +55,7 @@ struct DocumentationTests {
("SAFETY.md", "at most \(HelperRequest.maximumItems) items in one request"),
("SAFETY.md", "and the \(LibraryFolder.plugIns.count) that hold plug-ins"),
("ARCHITECTURE.md", "at most \(HelperRequest.maximumItems) items"),
+ ("ARCHITECTURE.md", "JSON keeps each value whole"),
("ARCHITECTURE.md", "answers, within \(Int(PrivilegedHelper.answerWait)) seconds"),
("ARCHITECTURE.md", "at most \(Int(PrivilegedHelper.requestWait)) seconds for a request"),
("SAFETY.md", "quits \(idle) seconds after its last request ends"),