Getting rid of the main function

Hi there.

I’m currently written a Kotlin DSL for the

While the DSL looks nice, it bothers me that I need to wrap it in a main function.

fun main(args: Array<String>) {
    router {
        serviceProxy(name = "names", port = 2000) {
            path(regExp = false, value = "/(rest)?names.*")

           rewriter {
           map(from = “^/names/(.*)”, to = “/restnames/name</span>.groovy</span>?name=$1”)

           target(host =, port = 80)

Is there some way to get rid of the main function? I'm basically looking for a way to execute the DSL as a script,

There is half-baked support for Kotlin scripts. See at the bottom about how to run a script. Also you may want to check this: