Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binarybirds/shell-kit
Shell is a simple package that gives you the ability to call shell commands through Swift.
https://github.com/binarybirds/shell-kit
shell swift swift-5
Last synced: 10 days ago
JSON representation
Shell is a simple package that gives you the ability to call shell commands through Swift.
- Host: GitHub
- URL: https://github.com/binarybirds/shell-kit
- Owner: BinaryBirds
- License: mit
- Created: 2020-04-20T06:40:59.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-23T10:09:04.000Z (4 months ago)
- Last Synced: 2024-10-01T16:49:46.722Z (about 2 months ago)
- Topics: shell, swift, swift-5
- Language: Swift
- Homepage:
- Size: 5.86 KB
- Stars: 13
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ShellKit (🥚)
Shell is a simple package that gives you the ability to call shell commands through Swift.
## Usage
Run (sync):
```swift
import ShellKitlet output = try Shell().run("ls ~")
```Run (async):
```swift
import ShellKitShell().run("sleep 2 && ls ~") { result, error in
//...
}
```Shell (bash) with environment variables:
```swift
import ShellKitlet shell = Shell("/bin/bash", env: ["ENV_SAMPLE_KEY": "Hello world!"])
let out = try shell.run("echo $ENV_SAMPLE_KEY")
```You can even set custom ouptut & error handlers.
## Install
Just use the [Swift Package Manager](https://theswiftdev.com/2017/11/09/swift-package-manager-tutorial/) as usual:
```swift
.package(url: "https://github.com/binarybirds/shell-kit", from: "1.0.0"),
```Don't forget to add "ShellKit" to your target as a dependency:
```swift
.product(name: "ShellKit", package: "shell-kit"),
```That's it.
## License
[WTFPL](LICENSE) - Do what the fuck you want to.