Kotlin multiplatform shell command runner.
execKmd("git checkout .")
Warning
This project is being actively developed but is in an early experimental state. Use the library cautiously and report back any issues. mooncloak is not responsible for any issues faced when using the library.
Checkout the releases page to get the latest version.
repositories {
maven("https://repo.repsy.io/mvn/mooncloak/public")
}
implementation("com.mooncloak.kodetools.kmd:kmd-core:VERSION")
val result = execKmd("git checkout .")
if (result.exitCode.isSuccessful()) {
// Do something
}
execKmd(
command = "run some command",
onStandardOut = { output ->
println(output.diffLines.joinToString(separator = "\n"))
},
onStandardError = { error ->
println("ERROR: ${error.diffLines.joinToString(separator = "\n")}")
})
// Deferring the processing of the result
val deferred = kmd(
command = "git checkout .",
coroutineScope = myScope
).async()
val result = deferred.await()
// Suspend until the command is finished processing
val result = kmd("git checkout .")
.await()
// Using a Flow to process the command result
kmd("git checkout .")
.flow()
.onEach { result -> println(result.exitCode.value) }
.launchIn(coroutineScope)
kmdBuilder("git checkout .")
.onStandardOut {}
.onStandardError {}
.build()
val checkout = kmdBuilder("git checkout .")
.onStandardOut {}
.onStandardError {}
.build()
val status = kmdBuilder("git status")
.onStandardOut {}
.onStandardError {}
.build()
checkout.then(status)
.build()
.await()
More detailed documentation is available in the docs folder. The entry point to the documentation can be found here.
For security vulnerabilities, concerns, or issues, please refer to the security policy for more information on appropriate approaches for disclosure.
Outside contributions are welcome for this project. Please follow the code of conduct and coding conventions when contributing. If contributing code, please add thorough documents and tests. Thank you!
Copyright 2025 mooncloak
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.