Swiftpack.co -  Package - leavez/Shell
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
leavez/Shell
Simple framework to run shell commands
.package(url: "https://github.com/leavez/Shell.git", from: "1.0.1")

Shell

Simple framework to run shell commands, fast.

// -- run and get result --
let output = Shell.run("ls")
if let err = output.error() {
    // including launch error or return non-zero code (with stderr as error message)
    throw err 
}
// output.exitCode
// output.stdout
// output.stderror

// -- run and print to stdout/stderr --
try Shell.runAndPrint("ls", "./")

// -- run bash script --
let output = Shell.run(bash: "ls")
try Shell.runAndPrint(bash: "ls ./")

Why another shell framework?

Shell is highly inspired by SwiftShell and copied a lot of code from it. So why another lib? The main reason is SwiftShell use Process.waitUntilExit and it cause slow execution for simple commands. SwiftShell is full featured and has a clear API. But when I fixing this problem, I feel its implementation a little bit complex for basic shell calls. So Shell comes, with simple implementations and is easy to modify. It also provides a new error checking API, convenient for programs with a lot of shell interactions.

License

MIT

GitHub

link
Stars: 0
Last commit: 3 weeks ago

Release Notes

3 weeks ago

fix stuck when stderr is long

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco