diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-27 13:11:19 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-27 13:11:19 +0200 |
| commit | 35def2831acd67ace6943e06f502a356529c3357 (patch) | |
| tree | 1a85aed55b64df33f0a9279da21c0dfd629d7f08 /src/main/java/simulator/VSMain.java | |
| parent | f55d67d98dddf5861dc4266564863dde4b0b6ed1 (diff) | |
Auto-open CLI simulation files on startup
Diffstat (limited to 'src/main/java/simulator/VSMain.java')
| -rw-r--r-- | src/main/java/simulator/VSMain.java | 25 |
1 files changed, 22 insertions, 3 deletions
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 @@ -51,6 +51,21 @@ public class VSMain { } /** + * 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. * * @param args the arguments @@ -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); } } |
