Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

fix(app): log command line runs too

raymondchinsc7e08c5ccc4e
diff --git a/app/Sources/BridgeplayApp/App.swift b/app/Sources/BridgeplayApp/App.swift
index 124eced..339af91 100644
--- a/app/Sources/BridgeplayApp/App.swift
+++ b/app/Sources/BridgeplayApp/App.swift
@@ -10,11 +10,6 @@ struct BridgeplayApp: App {
@State private var showsSetup = false
private let updater = AppUpdater.shared
- init() {
- AppLog.start()
- MigrationLaunch.shared.logLaunchResult()
- }
-
var body: some Scene {
Window("Bridgeplay", id: "main") {
RootView(pane: $pane)
diff --git a/app/Sources/BridgeplayApp/Support/AppLog.swift b/app/Sources/BridgeplayApp/Support/AppLog.swift
index 1749dac..5f249c8 100644
--- a/app/Sources/BridgeplayApp/Support/AppLog.swift
+++ b/app/Sources/BridgeplayApp/Support/AppLog.swift
@@ -24,6 +24,14 @@ enum AppLog {
queue.async { append(line) }
}
+ // The command line paths exit() as soon as they finish, which would drop queued lines,
+ // so they pass their exit status through here first.
+ static func finished(_ status: Int32) -> Int32 {
+ note("command line: exit \(status)")
+ queue.sync {}
+ return status
+ }
+
static func note(_ snapshot: StatusSnapshot) {
var lines = [
"state steam=\(describe(snapshot.steam))",
diff --git a/app/Sources/BridgeplayApp/Support/InstallIntoSteamCommand.swift b/app/Sources/BridgeplayApp/Support/InstallIntoSteamCommand.swift
index 59fd61e..811d601 100644
--- a/app/Sources/BridgeplayApp/Support/InstallIntoSteamCommand.swift
+++ b/app/Sources/BridgeplayApp/Support/InstallIntoSteamCommand.swift
@@ -6,7 +6,7 @@ enum InstallIntoSteamCommand {
static let flag = "--install-into-steam"
static func run() -> Never {
- Task.detached { exit(await perform()) }
+ Task.detached { exit(AppLog.finished(await perform())) }
dispatchMain()
}
@@ -37,6 +37,7 @@ enum InstallIntoSteamCommand {
say("Bridgeplay \(result.version) installed into Steam.")
return 0
} catch {
+ AppLog.note("command line failed: \(RemoveEverythingCommand.failureMessage(error))")
FileHandle.standardError.write(Data("\(RemoveEverythingCommand.failureMessage(error))\n".utf8))
return 1
}
diff --git a/app/Sources/BridgeplayApp/Support/Launch.swift b/app/Sources/BridgeplayApp/Support/Launch.swift
index 5de4204..196f87a 100644
--- a/app/Sources/BridgeplayApp/Support/Launch.swift
+++ b/app/Sources/BridgeplayApp/Support/Launch.swift
@@ -5,21 +5,27 @@ enum Launch {
static func main() {
// Before anything opens the support folder: the 3.0.0 move needs the old one intact.
MainActor.assumeIsolated { MigrationLaunch.shared.runAtLaunch() }
+ #if DEBUG
+ if CommandLine.arguments.dropFirst().contains(SetupPreviewApp.flag) {
+ SetupPreviewApp.main()
+ return
+ }
+ #endif
+ // The command line paths log as well, so a scripted run leaves the same trail.
+ AppLog.start()
+ MainActor.assumeIsolated { MigrationLaunch.shared.logLaunchResult() }
if CommandLine.arguments.dropFirst().contains(RemoveEverythingCommand.flag) {
+ AppLog.note("command line: \(RemoveEverythingCommand.flag)")
RemoveEverythingCommand.run()
}
if CommandLine.arguments.dropFirst().contains(InstallIntoSteamCommand.flag) {
+ AppLog.note("command line: \(InstallIntoSteamCommand.flag)")
InstallIntoSteamCommand.run()
}
if CommandLine.arguments.dropFirst().contains(SetupWinecxCommand.flag) {
+ AppLog.note("command line: \(SetupWinecxCommand.flag)")
SetupWinecxCommand.run()
}
- #if DEBUG
- if CommandLine.arguments.dropFirst().contains(SetupPreviewApp.flag) {
- SetupPreviewApp.main()
- return
- }
- #endif
BridgeplayApp.main()
}
}
diff --git a/app/Sources/BridgeplayApp/Support/RemoveEverythingCommand.swift b/app/Sources/BridgeplayApp/Support/RemoveEverythingCommand.swift
index 08f581b..cc9b03d 100644
--- a/app/Sources/BridgeplayApp/Support/RemoveEverythingCommand.swift
+++ b/app/Sources/BridgeplayApp/Support/RemoveEverythingCommand.swift
@@ -4,7 +4,7 @@ enum RemoveEverythingCommand {
static let flag = "--remove-everything"
static func run() -> Never {
- Task.detached { exit(await perform()) }
+ Task.detached { exit(AppLog.finished(await perform())) }
dispatchMain()
}
@@ -25,6 +25,7 @@ enum RemoveEverythingCommand {
)
return result.partialRemoval == nil ? 0 : 1
} catch {
+ AppLog.note("command line failed: \(failureMessage(error))")
FileHandle.standardError.write(Data("\(failureMessage(error))\n".utf8))
return 1
}
diff --git a/app/Sources/BridgeplayApp/Support/SetupWinecxCommand.swift b/app/Sources/BridgeplayApp/Support/SetupWinecxCommand.swift
index b5cd746..f101402 100644
--- a/app/Sources/BridgeplayApp/Support/SetupWinecxCommand.swift
+++ b/app/Sources/BridgeplayApp/Support/SetupWinecxCommand.swift
@@ -8,7 +8,7 @@ enum SetupWinecxCommand {
static let flag = "--setup-winecx"
static func run() -> Never {
- Task.detached { exit(await perform()) }
+ Task.detached { exit(AppLog.finished(await perform())) }
dispatchMain()
}
@@ -48,6 +48,7 @@ enum SetupWinecxCommand {
say("WineCX is set up.")
return 0
} catch {
+ AppLog.note("command line failed: \(RemoveEverythingCommand.failureMessage(error))")
FileHandle.standardError.write(Data("\(RemoveEverythingCommand.failureMessage(error))\n".utf8))
return 1
}