diff --git a/Brewlet/AppDelegate.swift b/Brewlet/AppDelegate.swift index d261cc8..baaf698 100644 --- a/Brewlet/AppDelegate.swift +++ b/Brewlet/AppDelegate.swift @@ -139,6 +139,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, PreferencesDelegate { */ @IBAction func update_upgrade(sender: NSMenuItem?) { let animation = animateIcon() + + var upgrade_command = "upgrade" + if self.userDefaults.bool(forKey: "dontUpgradeCasks") { + upgrade_command += " --formula" + } // Determine which packages to include let includeDependencies = self.userDefaults.bool(forKey: "includeDependencies") @@ -148,18 +153,18 @@ class AppDelegate: NSObject, NSApplicationDelegate, PreferencesDelegate { let shouldUpgrade = self.packages.filter(criterion).count > 0 - let command = shouldUpgrade && sender != nil ? "upgrade" : "update" + let command = shouldUpgrade && sender != nil ? upgrade_command : "update" let tmpFile = getLogFile() let updateItem = self.statusMenu.item(withTag: self.name2tag["update"]!)! updateItem.isEnabled = false - updateItem.title = command == "upgrade" ? "Upgrading..." : "Updating..." + updateItem.title = command == "update" ? "Updating..." : "Upgrading..." let packageItem = self.statusMenu.item(withTag: self.name2tag["packages"]!)! packageItem.isEnabled = false self.run_command(arguments: [command], fileRedirect: tmpFile) { _,_ in - os_log("Ran %s command.", type: .info, command) + os_log("Ran command: `%s`.", type: .info, command) updateItem.isEnabled = true animation.invalidate() diff --git a/Brewlet/PreferencesController.swift b/Brewlet/PreferencesController.swift index 033dee0..2acf933 100644 --- a/Brewlet/PreferencesController.swift +++ b/Brewlet/PreferencesController.swift @@ -23,6 +23,7 @@ class PreferencesController: NSWindowController { @IBOutlet weak var shareAnalytics: NSButton! @IBOutlet weak var autoUpgrade: NSButton! @IBOutlet weak var dontNotifyAvailable: NSButton! + @IBOutlet weak var dontUpgradeCasks: NSButton! @IBOutlet weak var brewPath: NSTextField! @IBOutlet weak var intel: NSButton! @IBOutlet weak var appleSilicon: NSButton! @@ -103,6 +104,11 @@ class PreferencesController: NSWindowController { UserDefaults.standard.set(sender.state == .on, forKey: "dontNotify") } + @IBAction func dontUpgradeCasksChanged(_ sender: NSButton) { + os_log("Update don't upgrade casks: %s", type: .info, sender.state == .on ? "on" : "off") + UserDefaults.standard.set(sender.state == .on, forKey: "dontUpgradeCasks") + } + @IBAction func updateIntervalChanged(_ sender: NSSlider) { var seconds: TimeInterval? = nil diff --git a/Brewlet/PreferencesController.xib b/Brewlet/PreferencesController.xib index c811c4d..dc14055 100644 --- a/Brewlet/PreferencesController.xib +++ b/Brewlet/PreferencesController.xib @@ -1,8 +1,8 @@ - + - + @@ -13,6 +13,7 @@ + @@ -25,14 +26,14 @@ - + - + - + @@ -42,7 +43,7 @@ - + @@ -51,7 +52,7 @@ - + @@ -60,7 +61,7 @@ - + @@ -69,7 +70,7 @@ - + @@ -78,7 +79,7 @@ - + @@ -87,7 +88,7 @@ - + - + - + @@ -201,12 +202,31 @@ + + - +