From 95c93ae03c60291f2574d1acd05f362a6f2e4bf8 Mon Sep 17 00:00:00 2001 From: Frotty Date: Thu, 9 Jul 2026 15:33:21 +0200 Subject: [PATCH] exportobjects command --- src/main/kotlin/file/CLICommand.kt | 1 + src/main/kotlin/file/SetupApp.kt | 38 +++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/file/CLICommand.kt b/src/main/kotlin/file/CLICommand.kt index 0f89b82..1080ff6 100644 --- a/src/main/kotlin/file/CLICommand.kt +++ b/src/main/kotlin/file/CLICommand.kt @@ -12,6 +12,7 @@ enum class CLICommand { TYPECHECK, OUTDATED, BUILD, + EXPORTOBJECTS, SELF_UPDATE } diff --git a/src/main/kotlin/file/SetupApp.kt b/src/main/kotlin/file/SetupApp.kt index 7940c46..bb92658 100644 --- a/src/main/kotlin/file/SetupApp.kt +++ b/src/main/kotlin/file/SetupApp.kt @@ -116,7 +116,8 @@ object SetupApp { } setup.command == CLICommand.TEST || setup.command == CLICommand.TYPECHECK || - setup.command == CLICommand.BUILD -> { + setup.command == CLICommand.BUILD || + setup.command == CLICommand.EXPORTOBJECTS -> { // Only needs to know a compiler is present; skip the version subprocess and update check. InstallationManager.verifyInstallation(probeVersion = false) } @@ -149,6 +150,7 @@ object SetupApp { | typecheck Typecheck the project without building a map | outdated Check whether project dependencies are up to date | build Build the project using the given input map + | exportobjects Export object editor data to Wurst source | |Global options: | --quiet Suppress wurst output; only print errors and final result @@ -271,6 +273,25 @@ object SetupApp { } } } + setup.command == CLICommand.EXPORTOBJECTS -> { + progress("Exporting object editor data...") + val mapArg = if (setup.commandArg.isBlank()) { + val maps = findMaps() + when (maps.size) { + 0 -> { missingMap(); null } + 1 -> { log.info("Auto-detected map: ${maps[0].fileName}"); maps[0].fileName.toString() } + else -> { multipleMaps(maps); null } + } + } else setup.commandArg + if (mapArg != null) { + val mapPath = setup.projectRoot.resolve(mapArg) + if (!Files.exists(mapPath)) { + missingMap(mapArg) + } else if (InstallationManager.status != InstallationManager.InstallationStatus.NOT_INSTALLED) { + exportObjects(mapPath) + } + } + } setup.command == CLICommand.SELF_UPDATE -> { log.info("🔄 Updating...") try { @@ -978,6 +999,21 @@ object SetupApp { } } + private fun exportObjects(mapPath: Path) { + val args = ArrayList(InstallationManager.compilerLaunchCommand().toList()) + args.add("-exportobjects") + args.add(mapPath.toAbsolutePath().toString()) + + val result = startWurstProcess(args) + when (result.exitCode) { + 0 -> { pass("Object editor data exported."); ExitHandler.exit(0) } + else -> { + printCompilerFailure("exportobjects", result) + ExitHandler.exit(1) + } + } + } + private fun testProject(configData: WurstProjectConfigData) { val args = commonArgs(configData)