Giter Site home page Giter Site logo

eneko / processrunner Goto Github PK

View Code? Open in Web Editor NEW
18.0 3.0 1.0 271 KB

Execute child processes and system commands from Swift

License: MIT License

Swift 97.01% Makefile 1.56% Dockerfile 1.43%
swift system command cli shell swiftpm package child-process process

processrunner's Introduction

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: "[email protected]: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.

processrunner's People

Contributors

eneko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lgq2015

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.