https://kotlinlang.org logo
#opensource
Title
# opensource
e

elect

09/27/2021, 1:43 PM
so, after playing with DSL and scripting for a while, I'd like to share some of my latest utils/play scenarios, which are basically kotlin dsl wrappers: • kotlin.kts for
kotlin
and
kotlinc
shell command • gradle.kts for
gradle
slurm.kts for Slurm API hopefully they will come in handy to someone else
🎉 1
j

Javier

09/27/2021, 2:02 PM
it looks very good, I would like to see more samples, and more complex, tho
e

ephemient

09/27/2021, 3:48 PM
the way you construct a string command line is a bad idea, is problematic for arguments with spaces or special characters
e

elect

09/27/2021, 3:49 PM
I'm not covering all, this is just the product of what I needed with the available options/docs. However, it won't be hard to fix that, I guess it's just a matter of single/double quotes or?
e

ephemient

09/27/2021, 3:53 PM
no. build a list
listOf("command", "arg1", "arg2", ...)
and pass it to ProcessBuilder, it is designed to accept a list or varargs
e

elect

09/27/2021, 3:56 PM
ah, ok
does even this have to be split up or I can add it altogether?
Copy code
args += " -howtorun $it"
e

ephemient

09/27/2021, 4:16 PM
yes, it has to be split up
e

elect

09/27/2021, 4:37 PM
done, thanks for the tip
@Javier I'm gonna use them soon and update the wiki. In the meanwhile, you can give me some snippets which I'd be more than happy to show you how they would become in kts
8 Views