A Cleanup menu item runs brew cleanup; holding ⌥ swaps it for a purge variant (cleanup --prune=all, which also drops cached downloads of current versions). A new opt-out-by-default setting interposes a plain cleanup between the end of any upgrade path and its closing refetch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
53 lines
2.1 KiB
Swift
53 lines
2.1 KiB
Swift
import Foundation
|
|
|
|
/// UserDefaults-backed app settings. Booleans read false for unset keys,
|
|
/// which covers the disabled-by-default settings; enabled-by-default ones
|
|
/// get their fallback via registerDefaults() (consulted only when the user
|
|
/// has never changed the value — nothing is written to disk).
|
|
///
|
|
/// Launch-at-login is intentionally absent: SMAppService is its source of
|
|
/// truth, so storing a copy here could only drift out of sync.
|
|
enum Settings {
|
|
static func registerDefaults() {
|
|
UserDefaults.standard.register(defaults: [
|
|
"includeGreedyCasks": true,
|
|
"confirmBeforeUpgradeAll": true,
|
|
])
|
|
}
|
|
|
|
static var autoUpgradeFormulae: Bool {
|
|
get { UserDefaults.standard.bool(forKey: "autoUpgradeFormulae") }
|
|
set { UserDefaults.standard.set(newValue, forKey: "autoUpgradeFormulae") }
|
|
}
|
|
|
|
static var autoUpgradeCasks: Bool {
|
|
get { UserDefaults.standard.bool(forKey: "autoUpgradeCasks") }
|
|
set { UserDefaults.standard.set(newValue, forKey: "autoUpgradeCasks") }
|
|
}
|
|
|
|
static var notifyOnNewUpdates: Bool {
|
|
get { UserDefaults.standard.bool(forKey: "notifyOnNewUpdates") }
|
|
set { UserDefaults.standard.set(newValue, forKey: "notifyOnNewUpdates") }
|
|
}
|
|
|
|
static var showCountInMenuBar: Bool {
|
|
get { UserDefaults.standard.bool(forKey: "showCountInMenuBar") }
|
|
set { UserDefaults.standard.set(newValue, forKey: "showCountInMenuBar") }
|
|
}
|
|
|
|
static var includeGreedyCasks: Bool {
|
|
get { UserDefaults.standard.bool(forKey: "includeGreedyCasks") }
|
|
set { UserDefaults.standard.set(newValue, forKey: "includeGreedyCasks") }
|
|
}
|
|
|
|
static var confirmBeforeUpgradeAll: Bool {
|
|
get { UserDefaults.standard.bool(forKey: "confirmBeforeUpgradeAll") }
|
|
set { UserDefaults.standard.set(newValue, forKey: "confirmBeforeUpgradeAll") }
|
|
}
|
|
|
|
static var cleanupAfterUpgrade: Bool {
|
|
get { UserDefaults.standard.bool(forKey: "cleanupAfterUpgrade") }
|
|
set { UserDefaults.standard.set(newValue, forKey: "cleanupAfterUpgrade") }
|
|
}
|
|
}
|