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.

Peel.app carries peel's shell completions and manual page

Țugui Dragoșa8e1754755da
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 6830b1df..6a689e07 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -50,3 +50,7 @@ jobs:
# catalog is out of date. It reads the strings from the Debug build above, in `build/DerivedData`.
- name: The string catalogs are in step with the code
run: python3 Scripts/sync_localizations.py --check
+
+ # The manual page of `peel` is written by `Scripts/generate_manual.py` from the tool the build above made.
+ - name: The manual page is in step with the tool
+ run: python3 Scripts/generate_manual.py --check
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index 23ef9ce2..e75255ce 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -148,6 +148,10 @@ beside each item, stop there with `--dry-run`, ask unless given `-y`, exit 2 whe
removal couldn't finish, and write the same History the app shows. The tool never uses the helper. Everything it
prints goes through `Output`, in plain ASCII, so scripts can read it.
+The app's build puts the tool's shell completions, written by the tool it just built, and its manual page,
+`Support/peel.1`, in `Peel.app/Contents/Resources/completions` and `man` (the Command Line Documentation phase),
+where a Homebrew install takes them from.
+
## What Peel writes on disk
| Where | What |
@@ -176,7 +180,8 @@ refuses it.
folder swapped between the check and the move.
- A few tests read this Mac instead of a fixture, and the slowest ones run only when asked for
(`PEEL_TEST_THIS_MAC=1`).
-- `Scripts/sync_localizations.py --check` fails when a string catalog is behind the code.
+- `Scripts/sync_localizations.py --check` fails when a string catalog is behind the code, and
+ `Scripts/generate_manual.py --check` when the manual page of `peel` is behind the tool.
## Releases
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1896f9f9..69a92b0a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -37,7 +37,9 @@ swift test --package-path Packages/PeelCore
Build and test after every change, not only at the end. After a Debug build, run
`python3 Scripts/sync_localizations.py` so the string catalogs match the strings in the code. It refuses to run
-without build output rather than empty the catalogs.
+without build output rather than empty the catalogs. After changing a command of `peel`, run
+`python3 Scripts/generate_manual.py` as well, which writes its manual page, `Support/peel.1`, from the tool just
+built.
The app's four targets build with warnings as errors, and that is the bar a change has to clear. The package's
manifest doesn't set it, so ask for it on the command line to hold the package to the same bar:
@@ -66,11 +68,12 @@ PEEL_TEST_THIS_MAC=1 swift test --package-path Packages/PeelCore --filter Sugges
- `Packages/PeelCore/`: everything that decides and acts, with the tests. `PeelCore` scans, matches, and removes;
`PeelPrivileged` is the part the helper shares; `PeelCommandLine` holds the `peel` commands.
- `Localization/`: every translation, and nothing else: the string catalogs of the app and the Finder extension.
-- `Support/`: the Info.plists and the helper's launchd property list.
+- `Support/`: the Info.plists, the helper's launchd property list, and the manual page of `peel`.
- `Logo/`: the only source of the logo: the app icon (`Peel.icon`), the menu bar glyph, and `export.sh`, which
renders the PNGs the README shows.
-- `Scripts/`: `sync_localizations.py`, which keeps the catalogs in step with the code, and `release.sh`, which
- builds, signs, notarizes, and checks a release.
+- `Scripts/`: `sync_localizations.py`, which keeps the catalogs in step with the code, `generate_manual.py`,
+ which keeps the manual page in step with `peel`, and `release.sh`, which builds, signs, notarizes, and checks a
+ release.
- `readme-assets/`: the screenshots the README shows.
- `.github/`: the test workflow, the issue forms, and the pull request template.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
index 15331ebf..6f93e59f 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
@@ -32,6 +32,19 @@ struct CommandLineTests {
])
}
+ /// The app ships `Support/peel.1`, which `Scripts/generate_manual.py` writes from the tool. A command added to
+ /// the tool without the page being written again would be missing from `man peel`.
+ @Test func theManualPageNamesEveryCommand() throws {
+ let page = try String(contentsOf: StringCatalogTests.repository.appending(path: "Support/peel.1"), encoding: .utf8)
+ func names(of command: any ParsableCommand.Type) -> [String] {
+ command.configuration.subcommands.flatMap { [$0.configuration.commandName ?? ""] + names(of: $0) }
+ }
+
+ let missing = names(of: PeelCommand.self).filter { !page.contains(".It Em \($0)\n") }
+
+ #expect(missing.isEmpty, "Missing from Support/peel.1: \(missing). Run Scripts/generate_manual.py after a Debug build.")
+ }
+
/// A table is written at once, rather than a row at a time: a search lists up to 2,000 rows.
@Test func writesATableAtOnce() {
let collected = Output.Collected()
diff --git a/Peel.xcodeproj/project.pbxproj b/Peel.xcodeproj/project.pbxproj
index 4e4a9b2c..7e74aa4e 100644
--- a/Peel.xcodeproj/project.pbxproj
+++ b/Peel.xcodeproj/project.pbxproj
@@ -303,6 +303,7 @@
AA000000000000000000002E /* Embed Launch Daemon */,
AA000000000000000000003E /* Embed Foundation Extensions */,
AA000000000000000000004D /* Embed Command Line Tool */,
+ AA0000000000000000000059 /* Command Line Documentation */,
);
buildRules = (
);
@@ -410,6 +411,33 @@
};
/* End PBXResourcesBuildPhase section */
+/* Begin PBXShellScriptBuildPhase section */
+ AA0000000000000000000059 /* Command Line Documentation */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "$(TARGET_BUILD_DIR)/$(CONTENTS_FOLDER_PATH)/Helpers/peel",
+ "$(SRCROOT)/Support/peel.1",
+ );
+ name = "Command Line Documentation";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/completions/_peel",
+ "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/completions/peel.bash",
+ "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/completions/peel.fish",
+ "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/man/peel.1",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "# The shell completions and the manual page of the `peel` tool, which Homebrew installs from the app. The\n# completions come from the tool just built; the manual page is Support/peel.1, which\n# Scripts/generate_manual.py keeps in step with the tool.\nset -eu\ntool=\"$TARGET_BUILD_DIR/$CONTENTS_FOLDER_PATH/Helpers/peel\"\nresources=\"$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\"\nmkdir -p \"$resources/completions\" \"$resources/man\"\n\"$tool\" --generate-completion-script zsh > \"$resources/completions/_peel\"\n\"$tool\" --generate-completion-script bash > \"$resources/completions/peel.bash\"\n\"$tool\" --generate-completion-script fish > \"$resources/completions/peel.fish\"\ncp \"$SRCROOT/Support/peel.1\" \"$resources/man/peel.1\"\n";
+ };
+/* End PBXShellScriptBuildPhase section */
+
/* Begin PBXSourcesBuildPhase section */
AA0000000000000000000023 /* Sources */ = {
isa = PBXSourcesBuildPhase;
diff --git a/README.md b/README.md
index 0be6b738..e0765afb 100644
--- a/README.md
+++ b/README.md
@@ -231,8 +231,9 @@ Every command that moves something asks first, and takes `--dry-run` to only sho
question. Answering no exits with code 2, so `peel uninstall Foo && next-step` stops there. The command moves only
what the app would suggest, through the same checks, into the same History, and leaves anything that needs an
administrator to the app. It won't run under `sudo`. Most commands take `--json`, which lists without moving, and
-`peel uninstall --json` reports what moved, what stayed, and why. `peel --generate-completion-script zsh` writes
-completions for your shell.
+`peel uninstall --json` reports what moved, what stayed, and why. A Homebrew install also sets up its completions
+for zsh, bash, and fish and its manual page, `man peel`; otherwise `peel --generate-completion-script zsh` writes
+the completions for your shell.
<details>
<summary>All commands</summary>
diff --git a/Scripts/generate_manual.py b/Scripts/generate_manual.py
new file mode 100644
index 00000000..40a3b454
--- /dev/null
+++ b/Scripts/generate_manual.py
@@ -0,0 +1,53 @@
+"""Keeps the manual page of the `peel` tool, `Support/peel.1`, in step with the tool.
+
+Run after building the Debug configuration into `build/DerivedData`:
+ python3 Scripts/generate_manual.py writes the page when the tool says something new
+ python3 Scripts/generate_manual.py --check writes nothing, and exits 1 when the page is behind
+
+The page is written by `generate-manual`, the tool swift-argument-parser ships for its GenerateManual plugin, from
+what the built `peel` says about itself. The tool is built from the copy of swift-argument-parser the Debug build
+resolved, into `build/Tools`, so nothing is downloaded. The date on the page is the day its text last changed:
+a page whose text is the same keeps the date it has. The app build copies the page into Peel.app, and Homebrew
+installs it from there.
+"""
+import pathlib, subprocess, sys, tempfile
+
+PROJECT = pathlib.Path(__file__).resolve().parent.parent
+DERIVED = PROJECT / "build/DerivedData"
+ARGUMENT_PARSER = DERIVED / "SourcePackages/checkouts/swift-argument-parser"
+TOOL = DERIVED / "Build/Products/Debug/Peel.app/Contents/Helpers/peel"
+SCRATCH = PROJECT / "build/Tools/argument-parser"
+PAGE = PROJECT / "Support/peel.1"
+CHECK = "--check" in sys.argv[1:]
+
+
+def without_date(page):
+ """The page without its `.Dd` line, which says only when it was written."""
+ return [line for line in page.splitlines() if not line.startswith(".Dd ")]
+
+
+def main():
+ if not TOOL.exists() or not ARGUMENT_PARSER.exists():
+ sys.exit("Build Peel's Debug configuration into build/DerivedData first.")
+ subprocess.run(
+ ["swift", "build", "--package-path", ARGUMENT_PARSER, "--scratch-path", SCRATCH,
+ "-c", "release", "--target", "generate-manual"],
+ check=True, stdout=subprocess.DEVNULL,
+ )
+ with tempfile.TemporaryDirectory() as folder:
+ subprocess.run(
+ [SCRATCH / "release/generate-manual", TOOL, "--output-directory", folder],
+ check=True, stdout=subprocess.DEVNULL,
+ )
+ new = (pathlib.Path(folder) / "peel.1").read_text(encoding="utf-8")
+ old = PAGE.read_text(encoding="utf-8") if PAGE.exists() else ""
+ if without_date(new) == without_date(old):
+ print("Support/peel.1 is in step with the tool.")
+ return
+ if CHECK:
+ sys.exit("Support/peel.1 is behind the tool. Run python3 Scripts/generate_manual.py after a Debug build.")
+ PAGE.write_text(new, encoding="utf-8")
+ print("Wrote Support/peel.1.")
+
+
+main()
diff --git a/Support/peel.1 b/Support/peel.1
new file mode 100644
index 00000000..28ea58b7
--- /dev/null
+++ b/Support/peel.1
@@ -0,0 +1,292 @@
+.\" "Generated by swift-argument-parser"
+.Dd September 25, 2026
+.Dt PEEL 1
+.Os
+.Sh NAME
+.Nm peel
+.Nd "Find what apps leave behind and move it to the Trash."
+.Sh SYNOPSIS
+.Nm
+.Ar subcommand
+.Op Fl -version
+.Op Fl -help
+.Sh DESCRIPTION
+Peel only moves files to the Trash, so you can put them back. Items that need administrator access are left for the Peel app. The tool writes English whatever the Mac's language, since scripts read what it prints.
+.Bl -tag -width 6n
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.It Em apps
+List installed apps.
+.Bl -tag -width 6n
+.It Fl -json
+Print JSON instead of text.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em inventory
+Write out what is installed and where each app came from.
+.Pp
+A Brewfile only lists what Homebrew can install again; everything else would be a line that doesn't work.
+.Bl -tag -width 6n
+.It Fl -format Ar format
+What to write: text, json, csv, brewfile.
+.Pp
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em leftovers
+Show the files an app leaves behind.
+.Pp
+APP can be the path to the app, its bundle identifier, or its name.
+.Bl -tag -width 6n
+.It Ar app
+The app to inspect.
+.It Fl -all
+Include files that need review before removing them.
+.It Fl -json
+Print JSON instead of text.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em uninstall
+Move an app and its leftovers to the Trash.
+.Pp
+Only leftovers Peel suggests are included. Items that need administrator access stay where they are; remove them with the Peel app.
+The app itself moves first, so nothing of it goes to the Trash while it stays installed. Answering no exits with code 2; a removal that couldn't finish exits 1, and so does a privacy reset that didn't happen.
+.Bl -tag -width 6n
+.It Ar app
+The app to remove: its path, bundle identifier, or name.
+.It Fl -keep-leftovers
+Move only the app, not its leftovers.
+.It Fl -reset-privacy
+Also reset the app's privacy permissions, just before it moves, so it asks again if you reinstall it. The Trash can't bring them back.
+.It Fl -dry-run
+Show what would move without moving anything.
+.It Fl y , -yes
+Don't ask for confirmation.
+.It Fl -json
+Print JSON instead of text.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em orphans
+List files left by apps that are no longer installed, and move a group to the Trash.
+.Pp
+Nothing here is ever suggested, so --remove takes the identifier of one group. What Peel refuses to move, what it leaves for you to choose in the app, and what needs administrator access, stays.
+.Bl -tag -width 6n
+.It Ar group
+The group to move, as `peel orphans` names it in its first column.
+.It Fl -remove
+Move what Peel suggests to the Trash.
+.It Fl -dry-run
+Show what would go without moving anything.
+.It Fl y , -yes
+Don't ask for confirmation.
+.It Fl -json
+Print JSON instead of text.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em history
+List what Peel moved to the Trash.
+.Pp
+The same History the Peel app shows, written by both. Put a removal back with `peel restore`. With --refused, lists what Peel was asked to move and wouldn't, which nothing else keeps.
+.Bl -tag -width 6n
+.It Fl -limit Ar limit
+Show at most this many removals.
+.It Fl -refused
+List what stayed and why, instead of what moved.
+.It Fl -clear
+Forget every refusal on record. Only with --refused.
+.It Fl -json
+Print JSON instead of text.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em restore
+Put a removal back where it came from.
+.Pp
+ID is what `peel history` shows in its first column; the first few characters are enough.
+Items that need administrator access are left for the Peel app. Answering no exits with code 2; a restore that couldn't finish exits 1.
+.Bl -tag -width 6n
+.It Ar id
+The removal to put back.
+.It Fl -dry-run
+Show what would go back without moving anything.
+.It Fl y , -yes
+Don't ask for confirmation.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em exclusions
+Show and change what Peel leaves alone.
+.Pp
+The same list the Peel app keeps. Nothing excluded is scanned, offered, or moved by either.
+.Bl -tag -width 6n
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.It Em list
+Show what Peel leaves alone.
+.Bl -tag -width 6n
+.It Fl -json
+Print JSON instead of text.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em add
+Leave a file, a folder, or an app alone.
+.Pp
+A whole disk, a home folder, or a Library is refused: excluding one would leave every tool with nothing to show.
+.Bl -tag -width 6n
+.It Ar paths...
+Files or folders to leave alone.
+.It Fl -app Ar app
+An app to leave alone: its path, bundle identifier, or name.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em remove
+Stop leaving something alone.
+.Bl -tag -width 6n
+.It Ar paths...
+Files or folders to stop leaving alone.
+.It Fl -app Ar app
+An app to stop leaving alone: its path, bundle identifier, or name.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.El
+.It Em caches
+List caches of developer tools, and move them to the Trash.
+.Pp
+With --remove, only what Peel would suggest goes: never a toolchain, an account, a token, or something it couldn't measure. Name tools to narrow it down.
+.Bl -tag -width 6n
+.It Ar tools...
+Tools to look at, as `peel caches` names them. All of them when none is given.
+.It Fl -remove
+Move what Peel suggests to the Trash.
+.It Fl -dry-run
+Show what would go without moving anything.
+.It Fl y , -yes
+Don't ask for confirmation.
+.It Fl -json
+Print JSON instead of text.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em projects
+List what builds left behind in your projects, and move it to the Trash.
+.Pp
+A folder only counts when the file that makes it sits beside it. Projects changed in the last 7 days, and folders under a name that could mean anything, are listed but never suggested, and --remove moves only what is suggested.
+.Bl -tag -width 6n
+.It Ar folders...
+Folders your projects live in.
+.It Fl -remove
+Move what Peel suggests to the Trash.
+.It Fl -dry-run
+Show what would go without moving anything.
+.It Fl y , -yes
+Don't ask for confirmation.
+.It Fl -json
+Print JSON instead of text.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em duplicates
+Find folders and files with identical contents.
+.Pp
+Without folders, Peel scans Desktop, Documents, Downloads, Pictures, Movies, and Music. The first copy of each group is the one Peel suggests keeping. A folder is a copy of another only when every file under it matches, so what a folder already speaks for isn't listed again on its own.
+.Bl -tag -width 6n
+.It Ar folders...
+Folders to scan.
+.It Fl -kind Ar kind
+Only files of this kind.
+.Pp
+.It Fl -min-size Ar min-size
+Only files at least this large, and folders holding at least this much, like 500KB or 1.5GB.
+.It Fl -remove
+Move what Peel suggests to the Trash.
+.It Fl -dry-run
+Show what would go without moving anything.
+.It Fl y , -yes
+Don't ask for confirmation.
+.It Fl -json
+Print JSON instead of text.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em search
+Search the Spotlight index for files.
+.Bl -tag -width 6n
+.It Fl -name Ar name
+Part of the file name.
+.It Fl -kind Ar kind
+The kind of file.
+.Pp
+.It Fl -min-size Ar min-size
+Only files at least this large, like 500KB or 1.5GB.
+.It Fl -older-than Ar older-than
+Only files not modified in this many days.
+.It Fl -everywhere
+Search every volume mounted on this Mac, not only your home folder.
+.It Fl -json
+Print JSON instead of text.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em updates
+Check installed apps for updates.
+.Pp
+Peel reads the settings of the Peel app: which source it prefers, which apps it was told to leave alone, and which versions were skipped. Nothing is installed; apps with no feed are left out.
+.Bl -tag -width 6n
+.It Fl -all
+Show every app, not only those with an update.
+.It Fl -json
+Print JSON instead of text.
+.It Fl -version
+Show the version.
+.It Fl h , -help
+Show help information.
+.El
+.It Em help
+Show subcommand help information.
+.Bl -tag -width 6n
+.It Ar subcommands...
+.It Fl -version
+Show the version.
+.El
+.El
+.Sh "EXIT STATUS"
+.Ex -std
\ No newline at end of file