Latest 0.3.0
Homepage https://github.com/hectr/swift-shell-interface
License MIT
Platforms osx 10.13
Frameworks Foundation
Authors

Version
License
Platform

A shell interface built as a thin abstraction layer over Foundation’s Process.

Usage

// -- Simple use case example:

let shell = ExecuteCommand()
let result = shell.execute(command: "cat",
arguments: ["/tmp/log.0.txt", "/tmp/log.1.txt"],
waitUntilExit: true)

// -- Customization example:

var context = TaskContext()
context.environment = ["HOME": "/Users/me"]
context.workingDirectory = "/tmp/"

let bash = ExecuteCommand(pathToShell: "/bin/bash")
_ = bash.execute(command: "curl", arguments: ["http://example.org"], context: context, waitUntilExit:false)

// -- Error reporting examples:

print(result.standardError)

guard let terminationStatus = result.terminationStatus else {
    throw TaskFailure.stillRunning(domain: #function, code: #line)
}

guard terminationStatus == 0 else {
    throw TaskFailure.nonzeroTerminationStatus(
        domain: #function,
        code: #line,
        terminationStatus: terminationStatus,
        uncaughtSignal: result.terminatedDueUncaughtSignal
    )
}

guard !result.standardOutput.isEmpty else {
    throw TaskFailure.emptyOutput(domain: #function, code: #line)
}

Installation

ShellInterface is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "ShellInterface"

License

ShellInterface is available under the MIT license. See the LICENSE file for more info.

Alternatives

Latest podspec

{
    "name": "ShellInterface",
    "version": "0.3.0",
    "summary": "Shell interface",
    "description": "A shell interface built as a thin abstraction layer on top of Foundation's `Process`.",
    "homepage": "https://github.com/hectr/swift-shell-interface",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Heu0300ctor Marqueu0300s": "[email protected]"
    },
    "social_media_url": "https://twitter.com/elnetus",
    "platforms": {
        "osx": "10.13"
    },
    "source": {
        "git": "https://github.com/hectr/swift-shell-interface.git",
        "tag": "0.3.0"
    },
    "source_files": "Sources/ShellInterface/**/*",
    "frameworks": "Foundation"
}

Pin It on Pinterest

Share This