Kommand
Kotlin Native library for run external command
Architecture
Dependent
-
Heavily inspired by the rust-std
Command
. -
Based on the
ktor-io
, Inter-Process Communication(IPC) can be handled using pipes -
Kotlin Multiplatform 1.7.20 with new memory manager
-
Native for macOS/Linux/Mingw
System calls using POSIX api
-
JVM
Based
java.lang.ProcessBuilder
Usage
Dependency
build.gradle.kts
:
// ……
repositories {
mavenCentral()
}
// ……
dependencies {
implementation("com.kgit2:kommand:$lastVersion")
}
Quick Start
Inherit Standard I/O
Command("ping")
.arg("-c")
.args("5", "localhost")
.spawn()
.wait()
Piped I/O
val child = Command("ping")
.args("-c", "5", "localhost")
.stdout(Stdio.Pipe)
.spawn()
val stdoutReader: com.kgit2.io.Reader? = child.getChildStdout()
val lines: Sequence<String> = stdoutReader?.lines()
lines.forEach {
println(it)
}
Null I/O
Command("gradle")
.arg("build")
.stdout(Stdio.Null)
.spawn()
.wait()