Swiftpack.co -  dooZdev/ProcessPretty as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
dooZdev/ProcessPretty
Pretty process form spm script.
.package(url: "https://github.com/dooZdev/ProcessPretty.git", from: "0.0.8")

ProcessPretty

Commandline tool that is platform endepended. Its main features are

  • captures the output for evaluation before writing to console
  • outputs in colors with optional progress bar
  • offers generic way to run asynchronous processes

This code works on windows, linux and macos.

Getting Started

You will have to install swift standard library. Follow the Swift getting started guide for the platform of your choosing.

Integrate

You will need to know about using swift package manager.

Integrate in application using SPM, in Package.swift

.package(name: "ProcessPretty", url: "https://github.com/dooZdev/ProcessPretty.gitt", <#wanted version#>)

more info on https://swift.org/package-manager/

Usage

In a main.swilf or type with @main

Add import ProcessPretty to the beginning of every file.

Synchronous


let echoSync = try ProcessPretty(executable: "echo", arguments: ["something to output in sync"])
func sync() {
    do {
        try echoSync.run(in: #function, at: #filePath)
    } catch {
        exit(EXIT_FAILURE)
    }
}

sync()

This looks up task in the PATH accessible executables. If the executable for the process to run is not found make update the PATH value.


Inspiration

Inspiration for this is taken from jakeheis/SwiftCLI. SwiftCLI does more than just run a system process. It also makes Commands, a structured way to add arguments and options to a process you run on the commandline. As for commands we use Apple's swift-argument-parser SwiftCLI was too big to use. But the way to run a task is taken from that project and used here.

GitHub

link
Stars: 0
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

12 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics