Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/helje5/shell
Module exposing Unix command line tools as Swift 5 @dynamicCallable functions
https://github.com/helje5/shell
swift swift5
Last synced: 3 months ago
JSON representation
Module exposing Unix command line tools as Swift 5 @dynamicCallable functions
- Host: GitHub
- URL: https://github.com/helje5/shell
- Owner: helje5
- License: mit
- Created: 2018-12-21T16:13:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T17:34:58.000Z (about 2 years ago)
- Last Synced: 2024-10-11T12:25:43.283Z (4 months ago)
- Topics: swift, swift5
- Language: Swift
- Size: 16.6 KB
- Stars: 110
- Watchers: 5
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shell
![Swift5](https://img.shields.io/badge/swift-5-blue.svg)
![macOS](https://img.shields.io/badge/os-macOS-green.svg?style=flat)Module exposing Unix command line tools as Swift 5 @dynamicCallable functions
A few words of warning:
This is intended as a demo.
It should work just fine, but in the name of error handling and proper Swift
beauty,
you might want to approach forking processes differently 🤓
(BTW: PRs are welcome!)Part of this blog post:
[@dynamicCallable: Unix Tools as Swift Functions](http://www.alwaysrightinstitute.com/swift-dynamic-callable/).## Sample tool
The regular Swift Package Manager setup process:
```shell
mkdir ShellConsumerTest && cd ShellConsumerTest
swift package init --type executable
```Sample `main.swift`:
```swift
import Shellprint(shell.host("zeezide.de"))
```Sample `Package.swift`:
```swift
// swift-tools-version:5.0import PackageDescription
let package = Package(
name: "ShellConsumerTest",
dependencies: [
.package(url: "https://github.com/AlwaysRightInstitute/Shell.git",
from: "0.1.0"),
],
targets: [
.target(name: "ShellConsumerTest", dependencies: [ "Shell" ]),
]
)
```
Remember to add the dependency in two places. WET is best!> `swift run` and `swift test` patch the `$PATH` to just `/usr/bin`. You
> may want to run the binary directly to make lookup work properly.For this to work, you need to have Swift 5+ installed.
## Links
- [SE-0195 Dynamic Member Lookup](https://github.com/apple/swift-evolution/blob/master/proposals/0195-dynamic-member-lookup.md)
- [SE-0216 Dynamic Callable](https://github.com/apple/swift-evolution/blob/master/proposals/0216-dynamic-callable.md)
- Python [sh module](https://amoffat.github.io/sh/)## Who
Brought to you by
[ZeeZide](http://zeezide.de).
We like
[feedback](https://twitter.com/ar_institute),
GitHub stars,
cool [contract work](http://zeezide.com/en/services/services.html),
presumably any form of praise you can think of.