Swiftpack.co - Package - eneko/ProcessRunner

ProcessRunner

ProcessRunner

Release Swift 5.0 Build Status codecov codebeat badge Linux Compatible

Easily execute system commands from a Swift script or command line tool.

Features

  • ✅ Easily execute child processes with arguments
  • ✅ Easily execute shell commands with arguments
  • ✅ Capture output or stream to stdout/stderr in real time
  • ✅ Swift Package Manager compatible
  • ✅ Linux compatible 🐧

🚀 Executing child Processes from Swift scripts and CLI tools

Running child processes in Swift is not hard with Process, but it can be a bit tedious and repetitive.

System makes this task extremely easy. If you are familiar with Ruby scripting (Rakefile, Fastlane, Danger, etc), you will feel like home.

💻 Automatically redirect output to stdout

import ProcessRunner

try system(command: "echo hello world") // prints "hello world" to stdout

✇ Capture process output

import ProcessRunner

let output = try system(command: "echo hello world", captureOutput: true).standardOutput
print(output) // prints "hello world"

✔️ Check if process terminated gracefully

import ProcessRunner

print(try system(command: "echo hello world").success) // prints "true"

|> Easily execute Shell commands with pipes and redirects

import ProcessRunner

try system(shell: "echo hello cat > cat && cat cat | awk '{print $2}'") // prints "cat" to stdout

Installation

Add ProcessRunner to your Package.swift:

import PackageDescription

let package = Package(
    name: "YourPackage",
    dependencies: [
        .package(url: "git@github.com:eneko/ProcessRunner.git", from: "1.0.0"),
    ],
    targets: [
        .target(
            name: "YourTarget",
            dependencies: ["ProcessRunner"]),
    ]
)

💌 Contact

Follow and/or contact me on Twitter at @eneko.

👏 Contributions

If you find an issue, just open a ticket on it. Pull requests are warmly welcome as well.

👮‍♂️ License

System is licensed under the MIT license. See LICENSE for more info.

Github

link
Stars: 9

Dependencies

Releases

Release 1.0.0 - 2020-05-07 22:25:01

Enhancements

  • Allow specifying current directory for child process

Release 0.3.0 - 2020-05-04 23:58:09

Breaking Changes

  • Remove SwiftPM dependency. System is now dependency-free 🎉

Release 0.2.0 - 2019-11-02 16:19:48

  • Swift 5.0

Relese 0.1.0 - 2019-07-05 21:30:14

  • Dependency updates

0.0.1 - 2018-08-29 03:49:10

Initial release