From 33f6e0296e220a9c61e0617c7b41721a3e278391 Mon Sep 17 00:00:00 2001 From: Tonz Date: Sat, 28 Jun 2025 00:52:59 -0700 Subject: [PATCH 1/2] Allow spaces in filepath name by forwarding all arguments --- app/src/processing/app/Processing.kt | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/app/src/processing/app/Processing.kt b/app/src/processing/app/Processing.kt index 11555edf5..857ffb0e0 100644 --- a/app/src/processing/app/Processing.kt +++ b/app/src/processing/app/Processing.kt @@ -59,30 +59,23 @@ class LSP: SuspendingCliktCommand("lsp"){ } } -class LegacyCLI(val args: Array): SuspendingCliktCommand( "cli"){ + +class LegacyCLI(val args: Array): SuspendingCliktCommand("cli") { + override val treatUnknownOptionsAsArgs = true + override fun help(context: Context) = "Legacy processing-java command line interface" - val help by option("--help").flag() - val build by option("--build").flag() - val run by option("--run").flag() - val present by option("--present").flag() - val sketch: String? by option("--sketch") - val force by option("--force").flag() - val output: String? by option("--output") - val export by option("--export").flag() - val noJava by option("--no-java").flag() - val variant: String? by option("--variant") + val arguments by argument().multiple(default = emptyList()) - override suspend fun run(){ - val cliArgs = args.filter { it != "cli" } + override suspend fun run() { try { - if(build){ + if (arguments.contains("--build")) { System.setProperty("java.awt.headless", "true") } - // Indirect invocation since app does not depend on java mode + Class.forName("processing.mode.java.Commander") .getMethod("main", Array::class.java) - .invoke(null, *arrayOf(cliArgs.toTypedArray())) + .invoke(null, arguments.toTypedArray()) } catch (e: Exception) { throw InternalError("Failed to invoke main method", e) } From 08bdd8570583784fd499880c9e05eb7162e252ae Mon Sep 17 00:00:00 2001 From: Tonz Date: Sat, 28 Jun 2025 01:20:28 -0700 Subject: [PATCH 2/2] Still pass help as an argument so that Commander help is shown. (Remove clikt help message which is canceled by val help anyway). --- app/src/processing/app/Processing.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/processing/app/Processing.kt b/app/src/processing/app/Processing.kt index 857ffb0e0..5ed98dacf 100644 --- a/app/src/processing/app/Processing.kt +++ b/app/src/processing/app/Processing.kt @@ -63,8 +63,7 @@ class LSP: SuspendingCliktCommand("lsp"){ class LegacyCLI(val args: Array): SuspendingCliktCommand("cli") { override val treatUnknownOptionsAsArgs = true - override fun help(context: Context) = "Legacy processing-java command line interface" - + val help by option("--help").flag() val arguments by argument().multiple(default = emptyList()) override suspend fun run() {