• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Module exposing Unix command line tools as Swift 5 @dynamicCallable functions

Shell

Swift5 macOS

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.

Sample tool

The regular Swift Package Manager setup process:

mkdir ShellConsumerTest && cd ShellConsumerTest
swift package init --type executable

Sample main.swift:

import Shell

print(shell.host("zeezide.de"))

Sample Package.swift:

// swift-tools-version:5.0

import 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

Who

Brought to you by ZeeZide. We like feedback, GitHub stars, cool contract work, presumably any form of praise you can think of.

More Repositories

1

SwiftSockets

A simple GCD based socket wrapper for Swift.
Swift
277
star
2

dockSwiftOnARM

Playing with dockerizing Swift for Raspberry Pi
Dockerfile
121
star
3

SwiftyHTTP

A simple GCD based HTTP client and server, written in 'pure' Swift
Swift
117
star
4

SwiftyWasmer

A Swift API for the Wasmer WebAssembly Runtime
Swift
52
star
5

SwiftObjCBridge

A Swift Objective-C Bridge implemented using @dynamicCallable
Swift
45
star
6

MicroExpress

A micro web server framework on top of the official Swift HTTP API
Swift
29
star
7

NWHTTPProtocol

An HTTP protocol implementation (an `NWProtocolFramer`) and a tiny HTTP server for Network.framework
C
25
star
8

swift-arm2mac-x-compile-toolchain

SPM toolchain to cross compile macOS Swift binaries on a Raspberry Pi (yes, you read that right)
Shell
12
star
9

SwiftXmlRpc

An XML-RPC protocol implementation for Swift
Swift
12
star
10

MacroCows

A Swift macro plugin that expands Strings into ASCII Cows, right at compile time.
Swift
12
star
11

GTKKit

Write GTK (GNOME) Applications in Objective-C
Objective-C
10
star
12

SwiftyExpat

Simple wrapper for the Expat XML parser.
C
9
star
13

http-c-vs-swift

Test performance of http-parser in Swift and C
Swift
6
star
14

WebPackMiniS

A super simple mini version of WebPack written in Swift
Swift
5
star
15

MultiCrap

Quick hack to square-crop a folder of images
Swift
5
star
16

SQLite3Schema

A Swift library to fetch the schema from a SQLite3 database.
Swift
4
star
17

wren-swift

The wren scripting language as a Swift package, w/ some Swift API wrappers
C
4
star
18

libFoundation

An Objective-C Foundation library
Objective-C
2
star
19

helje5

The GitHub Home of Helge Heß
2
star
20

StaticCMS

GETobjects based static website generator
Java
1
star
21

swifter

Swifter - like Swift, but swift!
1
star
22

mod_objc1

Write Apache 1 modules in Objective-C via GNUstep/libFoundation
Objective-C
1
star