FlightOfStairs/skripting

★ 1Forks 0KotlinGitHub ↗Compare

README

Build Status License

Skripting

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.

Examples

Basics

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..."
}

Piping

val result = skript {
    chain { ls(dir.absolutePath); grep("txt"); wc("-l") }
}

println(result) // "2\n"

Redirection

val result = skript {
    pipeIn("hello world") { "cat"() }
}

println(result) // "hello world"

Contributors

FlightOfStairs

Issues