Hey all, In the KEEP, regarding running a standalo...
# scripting
e
Hey all, In the KEEP, regarding running a standalone script https://github.com/Kotlin/KEEP/blob/master/proposals/scripting-support.md#standalone-scripting, where does
/path/to/kotlin/script/runner
in
#! /path/to/kotlin/script/runner -some -params
really point to?
i
e.g. the following script (from 1.3. RC blog post with added shebang line) works for me:
Copy code
#!/usr/bin/env kotlinc -cp dist/kotlinc/lib/kotlin-main-kts.jar -script

@file:Repository("<https://jcenter.bintray.com>")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.11")

import kotlinx.html.*
import kotlinx.html.stream.*

print(createHTML().html {
    body {
        h1 { +"Hello, World!" }
    }
})
(provided that kotlin is installed, path to the
kotlin-main-kts.jar
is correct, the script has extension
.main.kts
, executable atribute is set, and the shell is unix-based)
so the answer is - they should point to some scripting host, in my example - to
kotlinc
with appropriate params.
n
about that.. i am guessing this makes it so it can magically take arguments, is that all needed to wire up commandline parameters to scripts ? is there any way to customize that behaviour when running it with
kotlinc --script
?
i
It accepts arguments, yes. The
kotlinc -script
tries to construct script using the arguments supplied, i.e. - converting argument strings to the expected args of the script. There is no customization here, at least not yet.
n
so i guess no implicit conversions either? say String -> File or String -> Int
i
Yes, when possible.
💯 2