Swiftpack.co - dooZdev/ProcessPretty as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by dooZdev.
dooZdev/ProcessPretty 0.0.8
Pretty process form spm script.
⭐️ 0
🕓 2 years ago
.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: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

2 years ago

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