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 asks only where the plan can be seen, and drops typed-ahead keys
Țugui Dragoș14d470eb3b14
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex f24ca6a7..024bb853 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -184,9 +184,10 @@ enum Output {return "Peel couldn't look inside \(listed), so something may be there that isn't listed."}- /// Whether the user can answer a question: standard input and standard error must both be a terminal. The- /// question goes to standard error, and with that redirected the user would see only a waiting cursor.- static var canAsk: Bool { isatty(STDIN_FILENO) == 1 && isatty(STDERR_FILENO) == 1 }+ /// Whether the user can answer a question about the plan printed above it: standard input, standard output and+ /// standard error must all be a terminal. The plan goes to standard output and the question to standard error,+ /// so with either redirected the user would answer without seeing it.+ static var canAsk: Bool { isatty(STDIN_FILENO) == 1 && isatty(STDOUT_FILENO) == 1 && isatty(STDERR_FILENO) == 1 }/// Throws when the user can't be asked. Commands call this from `validate()`, where ArgumentParser knows which/// subcommand was typed and so prints that subcommand's usage.@@ -198,10 +199,11 @@ enum Output {/// `peel uninstall Foo && next-step` would then run `next-step` anyway.static let declined = ExitCode(2)- /// Asks `question` on standard error, which reaches the terminal even when the output goes to a file. Throws- /// `declined` unless the user answers y or yes.+ /// Asks `question` on standard error, and throws `declined` unless the user answers y or yes. What was typed+ /// before the question appeared is dropped first, so a key pressed during a long scan never answers it.static func confirm(_ question: String) throws {try requireConfirmable()+ tcflush(STDIN_FILENO, TCIFLUSH)try? FileHandle.standardError.write(contentsOf: Data(plain("\(question) [y/N] ").utf8))let answer = readLine()?.trimmingCharacters(in: .whitespaces).lowercased()guard answer == "y" || answer == "yes" else {diff --git a/README.md b/README.mdindex d9ec41f4..03cf8bdb 100644--- a/README.md+++ b/README.md@@ -270,12 +270,13 @@ The command ships inside the app. Settings > General shows the Terminal commandHomebrew install puts it there for you.Every command that moves something asks first, and takes `--dry-run` to only show the plan and `-y` to skip the-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. 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.+question. It asks only where you can see the plan and answer, so with its output sent to a file or a pipe it needs+`-y`, and it ignores keys typed before the question appeared. 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. 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>