@@ -116,7 +116,8 @@ object SetupApp {
116116 }
117117 setup.command == CLICommand .TEST ||
118118 setup.command == CLICommand .TYPECHECK ||
119- setup.command == CLICommand .BUILD -> {
119+ setup.command == CLICommand .BUILD ||
120+ setup.command == CLICommand .EXPORTOBJECTS -> {
120121 // Only needs to know a compiler is present; skip the version subprocess and update check.
121122 InstallationManager .verifyInstallation(probeVersion = false )
122123 }
@@ -149,6 +150,7 @@ object SetupApp {
149150 | typecheck Typecheck the project without building a map
150151 | outdated Check whether project dependencies are up to date
151152 | build <mapfile> Build the project using the given input map
153+ | exportobjects <mapfile|folder> Export object editor data to Wurst source
152154 |
153155 |Global options:
154156 | --quiet Suppress wurst output; only print errors and final result
@@ -271,6 +273,25 @@ object SetupApp {
271273 }
272274 }
273275 }
276+ setup.command == CLICommand .EXPORTOBJECTS -> {
277+ progress(" Exporting object editor data..." )
278+ val mapArg = if (setup.commandArg.isBlank()) {
279+ val maps = findMaps()
280+ when (maps.size) {
281+ 0 -> { missingMap(); null }
282+ 1 -> { log.info(" Auto-detected map: ${maps[0 ].fileName} " ); maps[0 ].fileName.toString() }
283+ else -> { multipleMaps(maps); null }
284+ }
285+ } else setup.commandArg
286+ if (mapArg != null ) {
287+ val mapPath = setup.projectRoot.resolve(mapArg)
288+ if (! Files .exists(mapPath)) {
289+ missingMap(mapArg)
290+ } else if (InstallationManager .status != InstallationManager .InstallationStatus .NOT_INSTALLED ) {
291+ exportObjects(mapPath)
292+ }
293+ }
294+ }
274295 setup.command == CLICommand .SELF_UPDATE -> {
275296 log.info(" 🔄 Updating..." )
276297 try {
@@ -978,6 +999,21 @@ object SetupApp {
978999 }
9791000 }
9801001
1002+ private fun exportObjects (mapPath : Path ) {
1003+ val args = ArrayList (InstallationManager .compilerLaunchCommand().toList())
1004+ args.add(" -exportobjects" )
1005+ args.add(mapPath.toAbsolutePath().toString())
1006+
1007+ val result = startWurstProcess(args)
1008+ when (result.exitCode) {
1009+ 0 -> { pass(" Object editor data exported." ); ExitHandler .exit(0 ) }
1010+ else -> {
1011+ printCompilerFailure(" exportobjects" , result)
1012+ ExitHandler .exit(1 )
1013+ }
1014+ }
1015+ }
1016+
9811017 private fun testProject (configData : WurstProjectConfigData ) {
9821018 val args = commonArgs(configData)
9831019
0 commit comments