From c8da6919ffe60ce1ec5ee0505c1a9da22ae858d0 Mon Sep 17 00:00:00 2001 From: Greg ORIOL Date: Tue, 12 May 2026 22:47:22 +0200 Subject: [PATCH] Add an AppleScript command to reload machine configuration from disk --- Scripting/UTM.sdef | 10 +++++++++- Scripting/UTMScriptingVirtualMachineImpl.swift | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Scripting/UTM.sdef b/Scripting/UTM.sdef index 41af0f1e..3f71a6c5 100644 --- a/Scripting/UTM.sdef +++ b/Scripting/UTM.sdef @@ -397,8 +397,12 @@ + + + + - + @@ -408,6 +412,10 @@ + + + + diff --git a/Scripting/UTMScriptingVirtualMachineImpl.swift b/Scripting/UTMScriptingVirtualMachineImpl.swift index 2e5c775e..d8fab05c 100644 --- a/Scripting/UTMScriptingVirtualMachineImpl.swift +++ b/Scripting/UTMScriptingVirtualMachineImpl.swift @@ -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]