feat: add independent CLI launches and preserve shared video bookmarks
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user