mirror of https://github.com/cirruslabs/tart.git
chore: adding no-keyboard, no-pointer options for run (#1091)
This commit is contained in:
parent
b05c731510
commit
90d9500133
|
|
@ -266,6 +266,12 @@ struct Run: AsyncParsableCommand {
|
||||||
#endif
|
#endif
|
||||||
var noTrackpad: Bool = false
|
var noTrackpad: Bool = false
|
||||||
|
|
||||||
|
@Flag(help: ArgumentHelp("Disable the pointer"))
|
||||||
|
var noPointer: Bool = false
|
||||||
|
|
||||||
|
@Flag(help: ArgumentHelp("Disable the keyboard"))
|
||||||
|
var noKeyboard: Bool = false
|
||||||
|
|
||||||
mutating func validate() throws {
|
mutating func validate() throws {
|
||||||
if vnc && vncExperimental {
|
if vnc && vncExperimental {
|
||||||
throw ValidationError("--vnc and --vnc-experimental are mutually exclusive")
|
throw ValidationError("--vnc and --vnc-experimental are mutually exclusive")
|
||||||
|
|
@ -317,7 +323,14 @@ struct Run: AsyncParsableCommand {
|
||||||
if noTrackpad {
|
if noTrackpad {
|
||||||
throw ValidationError("--no-trackpad cannot be used with --suspendable")
|
throw ValidationError("--no-trackpad cannot be used with --suspendable")
|
||||||
}
|
}
|
||||||
|
if noKeyboard {
|
||||||
|
throw ValidationError("--no-keyboard cannot be used with --suspendable")
|
||||||
}
|
}
|
||||||
|
if noPointer {
|
||||||
|
throw ValidationError("--no-pointer cannot be used with --suspendable")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if noTrackpad {
|
if noTrackpad {
|
||||||
let config = try VMConfig.init(fromURL: vmDir.configURL)
|
let config = try VMConfig.init(fromURL: vmDir.configURL)
|
||||||
|
|
@ -394,7 +407,9 @@ struct Run: AsyncParsableCommand {
|
||||||
clipboard: !noClipboard,
|
clipboard: !noClipboard,
|
||||||
sync: VZDiskImageSynchronizationMode(diskOptions.syncModeRaw),
|
sync: VZDiskImageSynchronizationMode(diskOptions.syncModeRaw),
|
||||||
caching: VZDiskImageCachingMode(diskOptions.cachingModeRaw),
|
caching: VZDiskImageCachingMode(diskOptions.cachingModeRaw),
|
||||||
noTrackpad: noTrackpad
|
noTrackpad: noTrackpad,
|
||||||
|
noPointer: noPointer,
|
||||||
|
noKeyboard: noKeyboard
|
||||||
)
|
)
|
||||||
|
|
||||||
let vncImpl: VNC? = try {
|
let vncImpl: VNC? = try {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,9 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
|
||||||
clipboard: Bool = true,
|
clipboard: Bool = true,
|
||||||
sync: VZDiskImageSynchronizationMode = .full,
|
sync: VZDiskImageSynchronizationMode = .full,
|
||||||
caching: VZDiskImageCachingMode? = nil,
|
caching: VZDiskImageCachingMode? = nil,
|
||||||
noTrackpad: Bool = false
|
noTrackpad: Bool = false,
|
||||||
|
noPointer: Bool = false,
|
||||||
|
noKeyboard: Bool = false
|
||||||
) throws {
|
) throws {
|
||||||
name = vmDir.name
|
name = vmDir.name
|
||||||
config = try VMConfig.init(fromURL: vmDir.configURL)
|
config = try VMConfig.init(fromURL: vmDir.configURL)
|
||||||
|
|
@ -73,7 +75,9 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
|
||||||
clipboard: clipboard,
|
clipboard: clipboard,
|
||||||
sync: sync,
|
sync: sync,
|
||||||
caching: caching,
|
caching: caching,
|
||||||
noTrackpad: noTrackpad
|
noTrackpad: noTrackpad,
|
||||||
|
noPointer: noPointer,
|
||||||
|
noKeyboard: noKeyboard
|
||||||
)
|
)
|
||||||
virtualMachine = VZVirtualMachine(configuration: configuration)
|
virtualMachine = VZVirtualMachine(configuration: configuration)
|
||||||
|
|
||||||
|
|
@ -316,7 +320,9 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
|
||||||
clipboard: Bool = true,
|
clipboard: Bool = true,
|
||||||
sync: VZDiskImageSynchronizationMode = .full,
|
sync: VZDiskImageSynchronizationMode = .full,
|
||||||
caching: VZDiskImageCachingMode? = nil,
|
caching: VZDiskImageCachingMode? = nil,
|
||||||
noTrackpad: Bool = false
|
noTrackpad: Bool = false,
|
||||||
|
noPointer: Bool = false,
|
||||||
|
noKeyboard: Bool = false
|
||||||
) throws -> VZVirtualMachineConfiguration {
|
) throws -> VZVirtualMachineConfiguration {
|
||||||
let configuration = VZVirtualMachineConfiguration()
|
let configuration = VZVirtualMachineConfiguration()
|
||||||
|
|
||||||
|
|
@ -356,8 +362,16 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
|
||||||
configuration.keyboards = platformSuspendable.keyboardsSuspendable()
|
configuration.keyboards = platformSuspendable.keyboardsSuspendable()
|
||||||
configuration.pointingDevices = platformSuspendable.pointingDevicesSuspendable()
|
configuration.pointingDevices = platformSuspendable.pointingDevicesSuspendable()
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if noKeyboard {
|
||||||
|
configuration.keyboards = []
|
||||||
|
} else {
|
||||||
configuration.keyboards = vmConfig.platform.keyboards()
|
configuration.keyboards = vmConfig.platform.keyboards()
|
||||||
if noTrackpad {
|
}
|
||||||
|
|
||||||
|
if noPointer {
|
||||||
|
configuration.pointingDevices = []
|
||||||
|
} else if noTrackpad {
|
||||||
configuration.pointingDevices = vmConfig.platform.pointingDevicesSimplified()
|
configuration.pointingDevices = vmConfig.platform.pointingDevicesSimplified()
|
||||||
} else {
|
} else {
|
||||||
configuration.pointingDevices = vmConfig.platform.pointingDevices()
|
configuration.pointingDevices = vmConfig.platform.pointingDevices()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue