Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

wuseal/Kscript-Tools

Repository files navigation

Kscript Tools

Easy way to run shell command line in kotlin and other tools

Usage

Used in kscript:

@file:DependsOn("com.sealwu:kscript-tools:1.0.22")

Used in normal kotlin gradle projects

add into gradle dependencies

dependencies {
 implementation("com.sealwu:kscript-tools:1.0.22")
}

APIs

runCommand

Run a bash/shell command in kotlin code, also can run multi-lines bash/shell scripts

execute next kotlin code

"ls".runCommand()

output on console:

Applications Downloads MavenDep Pictures iOSProjects
Desktop IdeaProjects Movies Public scripts
Documents Library Music StudioProjects

evalBash

Run a bash/shell command in kotlin code, also can run multi-lines bash/shell scripts, The different with runCommand is that it can get the command run standard output and error output

execute next kotlin code

val date = evalBash("date").getOrThrow() //execute shell command `date` and get the command's output and set the content to date variable
println(date) //This will print Fri Aug 19 21:59:56 CEST 2022 on console
val year = date.substringAfterLast(" ") // will get 2022 and assign to `year`
println(year)

output on console:

Fri Aug 19 21:59:56 CEST 2022
2022

About

Tools for Kotlin/Kscript to easy run shell command in kotlin code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

Languages

AltStyle によって変換されたページ (->オリジナル) /