From 35def2831acd67ace6943e06f502a356529c3357 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 27 Mar 2026 13:11:19 +0200 Subject: Auto-open CLI simulation files on startup --- src/main/java/simulator/VSMain.java | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/main/java/simulator/VSMain.java') diff --git a/src/main/java/simulator/VSMain.java b/src/main/java/simulator/VSMain.java index 02f3e20..5718b72 100644 --- a/src/main/java/simulator/VSMain.java +++ b/src/main/java/simulator/VSMain.java @@ -50,6 +50,21 @@ public class VSMain { new VSSimulatorFrame(prefs, relativeTo); } + /** + * Resolves the initial simulation filename from the CLI arguments. + * + * @param args the arguments passed to main + * + * @return the first non-blank argument, or null if none was provided + */ + static String resolveStartupSimulationFile(String[] args) { + if (args == null || args.length == 0 || args[0] == null) + return null; + + String filename = args[0].trim(); + return filename.isEmpty() ? null : filename; + } + /** * The main method. * @@ -69,14 +84,18 @@ public class VSMain { javax.swing.JPopupMenu.setDefaultLightWeightPopupEnabled(false); VSPrefs prefs = VSDefaultPrefs.init(); VSRegisteredEvents.init(prefs); - + VSMain.prefs = prefs; + // Wait for splash screen to finish before showing main window try { Thread.sleep(3000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } - - new VSMain(prefs); + + VSSimulatorFrame simulatorFrame = new VSSimulatorFrame(prefs, null); + String startupSimulationFile = resolveStartupSimulationFile(args); + if (startupSimulationFile != null) + simulatorFrame.openAndStartSimulator(startupSimulationFile); } } -- cgit v1.2.3