feat: add independent CLI launches and preserve shared video bookmarks

This commit is contained in:
2026-10-11 12:47:08 +02:00
parent 537e8e2624
commit 0dce073287
10 changed files with 254 additions and 40 deletions
+7 -3
View File
@@ -14,7 +14,7 @@ enum TerebiCLI {
switch command {
case .help:
print(PlayerCommand.usage)
case .launch(let url):
case .launch(let url, let newInstance):
guard let executable = Bundle.main.executableURL else {
fail("Could not locate the CLI executable.", code: 69)
}
@@ -24,10 +24,14 @@ enum TerebiCLI {
fail(error, code: 69)
}
let configuration = NSWorkspace.OpenConfiguration()
configuration.createsNewApplicationInstance = newInstance
if newInstance, let url {
configuration.arguments = ["--open-media", url.absoluteString]
}
do {
// Launch without media first so SwiftUI creates its singleton window.
// Launch an application, not a document, so SwiftUI creates its singleton window.
_ = try await NSWorkspace.shared.openApplication(at: app, configuration: configuration)
if let url {
if !newInstance, let url {
_ = try await NSWorkspace.shared.open([url], withApplicationAt: app, configuration: configuration)
}
} catch {