Skip to content

Commit 17c54e8

Browse files
authored
Merge pull request #1162 from toniab/main
Legacy CLI to handle sketch paths with spaces.
2 parents 6e4f078 + ddcf0c7 commit 17c54e8

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

app/src/processing/app/Processing.kt

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,22 @@ class LSP: SuspendingCliktCommand("lsp"){
5959
}
6060
}
6161

62-
class LegacyCLI(val args: Array<String>): SuspendingCliktCommand( "cli"){
63-
override fun help(context: Context) = "Legacy processing-java command line interface"
62+
63+
class LegacyCLI(val args: Array<String>): SuspendingCliktCommand("cli") {
64+
override val treatUnknownOptionsAsArgs = true
6465

6566
val help by option("--help").flag()
66-
val build by option("--build").flag()
67-
val run by option("--run").flag()
68-
val present by option("--present").flag()
69-
val sketch: String? by option("--sketch")
70-
val force by option("--force").flag()
71-
val output: String? by option("--output")
72-
val export by option("--export").flag()
73-
val noJava by option("--no-java").flag()
74-
val variant: String? by option("--variant")
67+
val arguments by argument().multiple(default = emptyList())
7568

76-
override suspend fun run(){
77-
val cliArgs = args.filter { it != "cli" }
69+
override suspend fun run() {
7870
try {
79-
if(build){
71+
if (arguments.contains("--build")) {
8072
System.setProperty("java.awt.headless", "true")
8173
}
82-
// Indirect invocation since app does not depend on java mode
74+
8375
Class.forName("processing.mode.java.Commander")
8476
.getMethod("main", Array<String>::class.java)
85-
.invoke(null, *arrayOf<Any>(cliArgs.toTypedArray()))
77+
.invoke(null, arguments.toTypedArray())
8678
} catch (e: Exception) {
8779
throw InternalError("Failed to invoke main method", e)
8880
}

0 commit comments

Comments
 (0)