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
Exit 64 from peel with no subcommand
Țugui Dragoș1302c1488086
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swiftindex 0adb3a92..08651f2e 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift@@ -1009,7 +1009,8 @@ struct SearchCommand: AsyncParsableCommand {@Option(name: .customLong("min-size"), help: "Only files at least this large, like 500KB or 1.5GB.")var minimumSize: ByteSize?- @Option(name: .customLong("older-than"), help: "Only files not modified in this many days.")+ // Unconditional, or `-1` reads as an option and `validate` never says what is wrong with it.+ @Option(name: .customLong("older-than"), parsing: .unconditional, help: "Only files not modified in this many days.")var olderThan: Int?@Flag(help: "Search every disk on this Mac, not only your home folder. Network volumes aren't searched.")diff --git a/Packages/PeelCore/Sources/PeelCommandLine/PeelCommand.swift b/Packages/PeelCore/Sources/PeelCommandLine/PeelCommand.swiftindex f1f78466..2e74af9a 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/PeelCommand.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/PeelCommand.swift@@ -27,6 +27,12 @@ public struct PeelCommand: AsyncParsableCommand {public init() {}+ /// A command with no subcommand is wrong, so a script that lost its subcommand doesn't read a success.+ public func run() async throws {+ Output.note(Self.helpMessage())+ throw ExitCode.validationFailure+ }+/// Parses the process arguments and runs the matching command.////// Refuses to run as root. `access(2)` checks the real user ID, which `sudo` sets to root, so every file woulddiff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swiftindex 0f556f53..eb44c6b8 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift@@ -544,6 +544,32 @@ struct CommandLineTests {== "No leftovers Peel suggests. 11 files need review. Add --all to see them.")}+ @Test func withoutASubcommandItShowsTheHelpAndFails() async throws {+ let command = try #require(try PeelCommand.parseAsRoot([]) as? PeelCommand)+ let collected = Output.Collected()++ let failure = await Output.$collected.withValue(collected) { () async -> (any Error)? in+ do {+ try await command.run()+ return nil+ } catch {+ return error+ }+ }++ #expect((failure as? ExitCode)?.rawValue == 64)+ #expect(collected.notes.contains("USAGE: peel"))+ #expect(collected.output.isEmpty, "a script reading standard output finds no list there")+ }++ @Test func aNegativeAgeReachesTheCommandsOwnWords() throws {+ let failure = #expect(throws: (any Error).self) {+ try PeelCommand.parseAsRoot(["search", "--name", "report", "--older-than", "-1"])+ }++ #expect(PeelCommand.message(for: try #require(failure)).contains("--older-than can't be negative."))+ }+@Test func leftoversAndUninstallSayWhichAppFoldersCouldNotBeRead() {let folder = URL(filePath: "/Volumes/org.example.Sleeping/Apps")let scan = AppScan(apps: [], unreadable: [folder], needsFullDiskAccess: false)