Free, open-source macOS cleaner. CleanMyMac alternative with zero telemetry. Native SwiftUI, scheduled auto-cleaning, Xcode/Homebrew/system cache cleanup. MIT licensed.
Swift cache-cleanercleanmymaccleanupdisk-cleanerdisk-spacehomebrewmac-utilitymacosmacos-appmacos-cleanermacosxnativeossosxprivacyswiftswiftuisystem-cleanerxcode-cleaner
fix(cli): only enter CLI mode for known commands (#68)
Dávid Balatoni03372c18d2e0
diff --git a/PureMac/Logic/Utilities/CLI.swift b/PureMac/Logic/Utilities/CLI.swiftindex 96b4815..640acea 100644--- a/PureMac/Logic/Utilities/CLI.swift+++ b/PureMac/Logic/Utilities/CLI.swift@@ -1,6 +1,16 @@import Foundationstruct CLI {+ private static let knownCommands: Set<String> = [+ "scan", "disk-info", "list",+ "help", "--help", "-h",+ "version", "--version", "-v",+ ]++ static func isKnownCommand(_ arg: String) -> Bool {+ knownCommands.contains(arg)+ }+static func run() -> Never {let args = Array(CommandLine.arguments.dropFirst())diff --git a/PureMac/PureMacApp.swift b/PureMac/PureMacApp.swiftindex 68fd00e..fde9bff 100644--- a/PureMac/PureMacApp.swift+++ b/PureMac/PureMacApp.swift@@ -16,7 +16,11 @@ struct PureMacApp: App {@AppStorage("PureMac.OnboardingComplete") private var onboardingComplete = falseinit() {- if CommandLine.arguments.count > 1 {+ // Enter CLI mode only when the first arg is a known command. Xcode and+ // LaunchServices inject args like -NSDocumentRevisionsDebugMode and+ // -psn_<pid> that must not be interpreted as CLI commands.+ if let first = CommandLine.arguments.dropFirst().first,+ CLI.isKnownCommand(first) {CLI.run()}}