Upgrade to Pro — share decks privately, control downloads, hide ads and more …

KScript

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for oshai oshai
January 13, 2020

 KScript

Avatar for oshai

oshai

January 13, 2020
Tweet

More Decks by oshai

Other Decks in Technology

Transcript

  1. fun main() { println("Hello World!") } ››› kotlinc Hello.kt -include-runtime

    -d hello.jar ››› java -jar hello.jar Hello World!
  2. import java.io.File fun explore(current: File) { println(current.path) if (current.isDirectory) {

    current.listFiles().forEach { explore(it) } } } explore(File("../scripts")) ››› kotlinc -script FileExplorer.kts ../scripts ../scripts/requirements.txt ../scripts/pgdump_parser.py ../scripts/pgdump_diff.py ../scripts/update_schema.py ../scripts/.gitignore ../scripts/utils.py ../scripts/README.md
  3. println("Hello World!") ››› time kscript hello.kts Hello World! kscript hello.kts

    7.33s user 0.78s system 224% cpu 3.608 total ››› time kscript hello.kts Hello World! kscript hello.kts 0.49s user 0.18s system 120% cpu 0.555 total
  4. Input modes Script > kscript script-file.kts URL > kscript https://git.io/v1cG6

    Inline* > kscript 'println("Hi")' REPL > kscript -i test Text Processing > cat some_file | kscript -t 'lines .filter { "^de0[-0]*".toRegex().matches(it) } .map { it + "foo:" } .print() '
  5. Major Features Packaging into self executing jar (using Capsule) ›››

    kscript --package hello.kts [kscript] Packaging script 'hello' into standalone executable... [kscript] Finished packaging into 'hello'
  6. Issues encountered • Dependency resolution did not always work on

    my Mac (and errors were sometimes funky) • Auto completion in IDE is not always working as expected.