Skip to content

Commit 7bdb9ec

Browse files
transfer the option to config
1 parent 113cf87 commit 7bdb9ec

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

Sources/tart/Commands/Get.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fileprivate struct VMInfo: Encodable {
99
let DiskFormat: String
1010
let Size: String
1111
let Display: String
12+
let HideTitleBar: Bool
1213
let Running: Bool
1314
let State: String
1415
}
@@ -27,7 +28,7 @@ struct Get: AsyncParsableCommand {
2728
let vmConfig = try VMConfig(fromURL: vmDir.configURL)
2829
let memorySizeInMb = vmConfig.memorySize / 1024 / 1024
2930

30-
let info = VMInfo(OS: vmConfig.os, CPU: vmConfig.cpuCount, Memory: memorySizeInMb, Disk: try vmDir.sizeGB(), DiskFormat: vmConfig.diskFormat.rawValue, Size: String(format: "%.3f", Float(try vmDir.allocatedSizeBytes()) / 1000 / 1000 / 1000), Display: vmConfig.display.description, Running: try vmDir.running(), State: try vmDir.state().rawValue)
31+
let info = VMInfo(OS: vmConfig.os, CPU: vmConfig.cpuCount, Memory: memorySizeInMb, Disk: try vmDir.sizeGB(), DiskFormat: vmConfig.diskFormat.rawValue, Size: String(format: "%.3f", Float(try vmDir.allocatedSizeBytes()) / 1000 / 1000 / 1000), Display: vmConfig.display.description, HideTitleBar: vmConfig.hideTitleBar, Running: try vmDir.running(), State: try vmDir.state().rawValue)
3132
print(format.renderSingle(info))
3233
}
3334
}

Sources/tart/Commands/Run.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,6 @@ struct Run: AsyncParsableCommand {
280280
#endif
281281
var noTrackpad: Bool = false
282282

283-
@Flag(help: "Hide the title bar and ignore safe area for fullscreen style.")
284-
var hideTitleBar: Bool = false
285-
286283
mutating func validate() throws {
287284
if vnc && vncExperimental {
288285
throw ValidationError("--vnc and --vnc-experimental are mutually exclusive")
@@ -736,7 +733,7 @@ struct Run: AsyncParsableCommand {
736733
private func runUI(_ suspendable: Bool, _ captureSystemKeys: Bool) {
737734
MainApp.suspendable = suspendable
738735
MainApp.capturesSystemKeys = captureSystemKeys
739-
MainApp.hideTitleBar = hideTitleBar
736+
MainApp.hideTitleBar = vm!.config.hideTitleBar
740737
MainApp.main()
741738
}
742739
}

Sources/tart/Commands/Set.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ struct Set: AsyncParsableCommand {
3737
"""))
3838
var diskSize: UInt16?
3939

40+
@Flag(inversion: .prefixedNo, help: ArgumentHelp("Whether to hide the title bar and ignore safe area for fullscreen style"))
41+
var hideTitleBar: Bool? = nil
42+
4043
func run() async throws {
4144
let vmDir = try VMStorageLocal().open(name)
4245
var vmConfig = try VMConfig(fromURL: vmDir.configURL)
@@ -60,6 +63,10 @@ struct Set: AsyncParsableCommand {
6063

6164
vmConfig.displayRefit = displayRefit
6265

66+
if let hideTitleBar = hideTitleBar {
67+
vmConfig.hideTitleBar = hideTitleBar
68+
}
69+
6370
if randomMAC {
6471
vmConfig.macAddress = VZMACAddress.randomLocallyAdministered()
6572
}

Sources/tart/VMConfig.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ enum CodingKeys: String, CodingKey {
2626
case display
2727
case displayRefit
2828
case diskFormat
29+
case hideTitleBar
2930

3031
// macOS-specific keys
3132
case ecid
@@ -56,6 +57,7 @@ struct VMConfig: Codable {
5657
var display: VMDisplayConfig = VMDisplayConfig()
5758
var displayRefit: Bool?
5859
var diskFormat: DiskImageFormat = .raw
60+
var hideTitleBar: Bool = false
5961

6062
init(
6163
platform: Platform,
@@ -130,6 +132,7 @@ struct VMConfig: Codable {
130132
displayRefit = try container.decodeIfPresent(Bool.self, forKey: .displayRefit)
131133
let diskFormatString = try container.decodeIfPresent(String.self, forKey: .diskFormat) ?? "raw"
132134
diskFormat = DiskImageFormat(rawValue: diskFormatString) ?? .raw
135+
hideTitleBar = try container.decodeIfPresent(Bool.self, forKey: .hideTitleBar) ?? false
133136
}
134137

135138
func encode(to encoder: Encoder) throws {
@@ -149,6 +152,7 @@ struct VMConfig: Codable {
149152
try container.encode(displayRefit, forKey: .displayRefit)
150153
}
151154
try container.encode(diskFormat.rawValue, forKey: .diskFormat)
155+
try container.encode(hideTitleBar, forKey: .hideTitleBar)
152156
}
153157

154158
mutating func setCPU(cpuCount: Int) throws {

0 commit comments

Comments
 (0)