https://github.com/binarybirds/shell-kit
ShellKit is a simple package that gives you the ability to call shell commands through Swift.
https://github.com/binarybirds/shell-kit
shell shell-kit swift swift-5 swift-6
Last synced: 3 months ago
JSON representation
ShellKit 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 (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-01-27T19:51:54.000Z (5 months ago)
- Last Synced: 2025-04-12T04:44:18.724Z (3 months ago)
- Topics: shell, shell-kit, swift, swift-5, swift-6
- Language: Swift
- Homepage:
- Size: 12.7 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- 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.