Skripting is a Kotlin library and DSL intended to enable easy use of existing shell commands without having to descend to using a traditional shell scripting language.
Skripting is heavily inspired by the excellent Python library Plumbum.
skript {
val result = "ls"("-a")
println(result.trim().split("\n"))
// [., .., .git, .gitignore, .gradle, .idea, .kotlintest, .travis.yml, LICENSE, README.md, ...]
}Commands may be given as strings or otherwise:
val ls = Local("ls")
skript {
println(ls("-a")) // "LICENSE\nREADME.md\nbuild\n..."
}val result = skript {
chain { ls(dir.absolutePath); grep("txt"); wc("-l") }
}
println(result) // "2\n"val result = skript {
pipeIn("hello world") { "cat"() }
}
println(result) // "hello world"