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
Say each default of peel where its manual page shows it
Țugui Dragoșf3340962a55e
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swiftindex e230f2cc..9a06404c 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift@@ -28,11 +28,12 @@ struct InventoryCommand: AsyncParsableCommand {)/// An enum, so `--help` lists the formats and the shell can complete them.- @Option(help: "What to write.")- var format: FormatArgument = .text+ @Option(help: "What to write. Without it, \(FormatArgument.text.rawValue).")+ var format: FormatArgument?++ var chosen: Inventory.Format { (format ?? .text).format }func run() async throws {- let chosen = format.formatguard chosen != .brewfile else {Output.write(try Inventory.build(apps: [], brewfile: try await Self.brewfile()).written(as: chosen))returndiff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/ExclusionCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/ExclusionCommands.swiftindex f4aab1c4..ddec760e 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/ExclusionCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/ExclusionCommands.swift@@ -6,7 +6,7 @@ struct ExclusionsCommand: AsyncParsableCommand {static let configuration = CommandConfiguration(commandName: "exclusions",abstract: "Show and change what Peel leaves alone.",- discussion: "The same list the Peel app keeps. Nothing excluded is scanned, offered, or moved by either.",+ discussion: "The same list the Peel app keeps. Nothing excluded is scanned, offered, or moved by either. Without a subcommand, it shows the list.",subcommands: [ListCommand.self, AddCommand.self, RemoveCommand.self],defaultSubcommand: ListCommand.self)diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swiftindex 52d5358a..20aed7e2 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift@@ -45,8 +45,10 @@ struct HistoryCommand: AsyncParsableCommand {discussion: "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.")- @Option(help: "Show at most this many removals.")- var limit: Int = 20+ static let defaultLimit = 20++ @Option(help: "Show at most this many removals. Without it, \(defaultLimit).")+ var limit: Int?@Flag(help: "List what stayed and why, instead of what moved.")var refused = false@@ -146,13 +148,15 @@ struct HistoryCommand: AsyncParsableCommand {}func validate() throws {- guard limit > 0 else { throw ValidationError("--limit has to be at least 1.") }+ if let limit, limit < 1 { throw ValidationError("--limit has to be at least 1.") }guard !clear || refused else { throw ValidationError("--clear only goes with --refused. What moved is forgotten from History in the Peel app.") }guard !clear || !output.json else {throw ValidationError("--clear writes nothing to read, so it doesn't go with --json.")}}+ private var shown: Int { limit ?? Self.defaultLimit }+func run() async throws {try await run(in: RemovalLog(), refusals: RefusalLog())}@@ -163,7 +167,7 @@ struct HistoryCommand: AsyncParsableCommand {guard let records = outcome.records else {throw CommandFailure("Peel couldn't read its History.\(outcome.problem.map { " \($0.summary)" } ?? "")")}- let batches = Array(Batch.all(in: records).prefix(limit))+ let batches = Array(Batch.all(in: records).prefix(shown))if output.json {try Output.json(batches.map { batch in@@ -226,7 +230,7 @@ struct HistoryCommand: AsyncParsableCommand {if let problem = read.problem {Output.note(problem.summary)}- let removals = Array(RefusalRecord.grouped(records).prefix(limit))+ let removals = Array(RefusalRecord.grouped(records).prefix(shown))if output.json {try Output.json(removals.map { removal indiff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swiftindex 1cd06306..556b769c 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift@@ -909,6 +909,24 @@ struct CommandLineTests {}}+ /// The manual page leaves out the defaults `--help` marks, so each is said in words both show: an option's in+ /// its own help, and a default subcommand's in the discussion of the command above it.+ @Test func eachDefaultIsSaidWhereTheManualPageShowsIt() throws {+ func commands(under command: any ParsableCommand.Type) -> [any ParsableCommand.Type] {+ [command] + command.configuration.subcommands.flatMap { commands(under: $0) }+ }+ for command in commands(under: PeelCommand.self) {+ #expect(!command.helpMessage(columns: 300).contains("(default:"), "\(command)")+ if command.configuration.defaultSubcommand != nil {+ #expect(command.configuration.discussion.contains("Without a subcommand,"), "\(command)")+ }+ }+ #expect(HistoryCommand.helpMessage(columns: 300).contains("Show at most this many removals. Without it, 20."))+ #expect(InventoryCommand.helpMessage(columns: 300).contains("What to write. Without it, text."))+ #expect(try #require(try PeelCommand.parseAsRoot(["inventory"]) as? InventoryCommand).chosen == .text)+ #expect(ExclusionsCommand.configuration.discussion.hasSuffix("Without a subcommand, it shows the list."))+ }+/// Scripts read the exit status, so the help and the manual page name each code, and each is the one the tool/// really uses: ArgumentParser's own for a usage error, and Peel's for a "no" and a failure.@Test func namesTheExitCodesItUses() {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swiftindex 6242d006..ea19f5c5 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift@@ -197,18 +197,21 @@ struct HistoryCommandTests {#expect(try listed(try await printed(["history", "--refused", "--json"], from: logs)).isEmpty)}- /// `--limit` is what the command prints, in the table and in `--json` alike.+ /// `--limit` is what the command prints, in the table and in `--json` alike, and 20 without it.@Test func showsAtMostWhatWasAskedFor() async throws {let directory = try TemporaryDirectory()let logs = logs(in: directory)- _ = await logs.removals.add(try (0..<3).map { _ in try removal(in: directory).record })+ let count = HistoryCommand.defaultLimit + 1+ _ = await logs.removals.add(try (0..<count).map { _ in try removal(in: directory).record })let table = try await printed(["history", "--limit", "2"], from: logs)let json = try await printed(["history", "--limit", "2", "--json"], from: logs)+ let unlimited = try await printed(["history", "--json"], from: logs)#expect(table.split(separator: "\n").count == 3, "a header and two removals, not \(table)")#expect(try listed(json).count == 2)- #expect(Batch.all(in: try #require(await logs.removals.load().records)).count == 3, "listing forgot nothing")+ #expect(try listed(unlimited).count == 20)+ #expect(Batch.all(in: try #require(await logs.removals.load().records)).count == count, "listing forgot nothing")}/// What Peel could not measure is never printed as zero: the table says "over" while part of a removal isdiff --git a/Support/peel.1 b/Support/peel.1index 8d7bc1ef..2061e902 100644--- a/Support/peel.1+++ b/Support/peel.1@@ -33,7 +33,7 @@ Write out what is installed and where each app came from.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.+What to write. Without it, text..Pp.Bl -tag -width 6n.It Ar text@@ -115,7 +115,7 @@ List what Peel moved to the Trash.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.+Show at most this many removals. Without it, 20..It Fl -refusedList what stayed and why, instead of what moved..It Fl -clear@@ -147,7 +147,7 @@ Show help information..It Em exclusionsShow and change what Peel leaves alone..Pp-The same list the Peel app keeps. Nothing excluded is scanned, offered, or moved by either.+The same list the Peel app keeps. Nothing excluded is scanned, offered, or moved by either. Without a subcommand, it shows the list..Bl -tag -width 6n.It Fl -versionShow the version.