mirror of
https://github.com/utmapp/UTM.git
synced 2026-10-12 02:24:01 +00:00
Merge pull request #7711 from GregOriol/feat/scripting-reload-configuration
Add an AppleScript command to reload machine configuration from disk
This commit is contained in:
+9
-1
@@ -397,8 +397,12 @@
|
||||
<responds-to command="update configuration">
|
||||
<cocoa method="updateConfiguration:"/>
|
||||
</responds-to>
|
||||
|
||||
<responds-to command="reload configuration">
|
||||
<cocoa method="reloadConfiguration:"/>
|
||||
</responds-to>
|
||||
</class-extension>
|
||||
|
||||
|
||||
<command name="update configuration" code="UTMcUpDt" description="Update the configuration of the virtual machine. The VM must be in the stopped state.">
|
||||
<direct-parameter description="Virtual machine to configure." type="virtual machine"/>
|
||||
<parameter name="with" code="UpCf" description="The configuration to update the virtual machine. You cannot change the backend with this!">
|
||||
@@ -408,6 +412,10 @@
|
||||
</parameter>
|
||||
</command>
|
||||
|
||||
<command name="reload configuration" code="UTMcReLd" description="Reload the configuration of the virtual machine from disk, discarding any unsaved in-memory changes. Useful when the .utm bundle has been modified externally (e.g. by an automation tool) and UTM's cached configuration needs to be refreshed. The VM must be in the stopped state.">
|
||||
<direct-parameter description="Virtual machine to reload." type="virtual machine"/>
|
||||
</command>
|
||||
|
||||
<record-type name="qemu configuration" code="QeCf" description="QEMU virtual machine configuration.">
|
||||
<property name="name" code="pnam" type="text"
|
||||
description="Virtual machine name."/>
|
||||
|
||||
@@ -183,6 +183,15 @@ class UTMScriptingVirtualMachineImpl: NSObject, UTMScriptable {
|
||||
try await data.delete(vm: box, alsoRegistry: true)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func reloadConfiguration(_ command: NSScriptCommand) {
|
||||
withScriptCommand(command) { [self] in
|
||||
guard vm.state == .stopped else {
|
||||
throw ScriptingError.notStopped
|
||||
}
|
||||
try data.discardChanges(for: box)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func clone(_ command: NSCloneCommand) {
|
||||
let properties = command.evaluatedArguments?["WithProperties"] as? [AnyHashable : Any]
|
||||
|
||||
Reference in New Issue
Block a user