Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leavez/shell
Run shell commands fastly
https://github.com/leavez/shell
Last synced: about 1 month ago
JSON representation
Run shell commands fastly
- Host: GitHub
- URL: https://github.com/leavez/shell
- Owner: leavez
- Created: 2021-03-08T13:43:08.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-21T09:00:34.000Z (almost 2 years ago)
- Last Synced: 2024-03-15T15:21:51.788Z (8 months ago)
- Language: Swift
- Homepage:
- Size: 24.4 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Shell
Simple framework to run shell commands, fast.
```swift
// -- 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](https://github.com/kareman/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](https://github.com/kareman/SwiftShell/issues/101) 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