Getting rid of the main function


#1

Hi there.

I’m currently written a Kotlin DSL for the https://github.com/membrane/service-proxy.

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 = thomas-bayer.com, 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,


#2

There is half-baked support for Kotlin scripts. See http://kotlinlang.org/docs/tutorials/command-line.html at the bottom about how to run a script. Also you may want to check this: https://github.com/andrewoma/kotlin-script