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 when peel apps and peel inventory couldn't read every app
Țugui Dragoșad8a8516733a
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swiftindex 6575f969..e230f2cc 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift@@ -9,12 +9,14 @@ struct AppsCommand: AsyncParsableCommand {@OptionGroup var output: OutputOptionsfunc run() async throws {- let apps = await AppCatalog.installedApps()+ let catalog = await AppCatalog.scan()+ let apps = catalog.appsif output.json {try Output.json(apps.map(AppRecord.init))- return+ } else {+ Output.table([["NAME", "VERSION", "IDENTIFIER", "PATH"]] + apps.map { [$0.name, $0.version ?? "", $0.bundleIdentifier, Output.path($0.url)] })}- Output.table([["NAME", "VERSION", "IDENTIFIER", "PATH"]] + apps.map { [$0.name, $0.version ?? "", $0.bundleIdentifier, Output.path($0.url)] })+ if let note = Output.unreadableNote(for: catalog) { Output.note(note) }}}@@ -35,9 +37,10 @@ struct InventoryCommand: AsyncParsableCommand {Output.write(try Inventory.build(apps: [], brewfile: try await Self.brewfile()).written(as: chosen))return}- let apps = await AppCatalog.installedApps()- let inventory = Inventory.build(apps: apps, casks: await Self.casks(), origins: .onThisMac)+ let catalog = await AppCatalog.scan()+ let inventory = Inventory.build(apps: catalog.apps, casks: await Self.casks(), origins: .onThisMac)Output.write(try inventory.written(as: chosen))+ if let note = Output.unreadableNote(for: catalog) { Output.note(note) }}/// Returns Homebrew's own Brewfile, or fails with why: an empty one would look like a success until someonediff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 0e3c0a95..5663af6a 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -184,6 +184,13 @@ enum Output {return "Peel couldn't look inside \(listed), so something may be there that isn't listed."}+ /// What a reading of the apps could not read, so the apps in it are missing from what is written, or nil when it+ /// read everything.+ static func unreadableNote(for catalog: AppScan) -> String? {+ guard !catalog.unreadable.isEmpty else { return nil }+ return unreadableNote(for: catalog.unreadable, needsFullDiskAccess: catalog.needsFullDiskAccess)+ }+/// 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.diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swiftindex 99c1b725..1cd06306 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift@@ -23,6 +23,16 @@ struct CommandLineTests {)}+ @Test func aListOfAppsSaysWhatItCouldNotRead() {+ let studio = URL(filePath: "/Volumes/Studio/Apps", directoryHint: .isDirectory)++ #expect(Output.unreadableNote(for: AppScan(apps: [], unreadable: [], needsFullDiskAccess: false)) == nil)+ #expect(+ Output.unreadableNote(for: AppScan(apps: [], unreadable: [studio], needsFullDiskAccess: false))+ == "Peel couldn't look inside /Volumes/Studio/Apps, so something may be there that isn't listed."+ )+ }+@Test func parsesByteSizes() {#expect(ByteSize(argument: "2048")?.bytes == 2_048)#expect(ByteSize(argument: "500KB")?.bytes == 500_000)