import AppKit import ArgumentParser import Foundation extension phbar { struct start: ParsableCommand { static let configuration = CommandConfiguration( commandName: "start", abstract: "Start the status bar." ) @Flag(name: .long, help: "Display visual guides to help align elements.") var debug: Bool = false mutating func run() throws { let config = try PHConfig.load() // NOTE: Make sure NSApp.run() runs in the main thread dispatchPrecondition(condition: .onQueue(.main)) try MainActor.assumeIsolated { guard !NSScreen.screens.isEmpty else { throw CleanExit.message("No monitor found") } let delegate = PHBarDelegate(config: config, debug: debug) let app = NSApplication.shared app.setActivationPolicy(.accessory) app.delegate = delegate app.run() throw ExitCode.success } } } }