SwiftBar

develop

skunkrocker/SwiftBar

SwiftBar

Progress Bar for Command Line Tools written in Swift.

Fonts

It is strongly recommended to install Nerd Fonts It may not work with regular fonts.

Term Type

Dumb terminal is not supported

Installation

import PackageDescription

let package = Package(
        name: "Your Package",
        dependencies: [
            .package(url: "https://github.com/skunkrocker/SwiftBar.git", from: "1.0.2")
        ]
)

Usage

Unknown duration

Usage for Tasks of unknown duration, call the infinite (aeon) function block:

print("Signal Type".bold)
let signalMsg = "🔥 Long Job".bold + " .signal ".blue + " type".bold
let signalCompleteMsg = "Long Job".bold + " .signal ".blue + "type done".bold
waitForAsync { stopWaiting in
    aeon(.signal, signalMsg, signalCompleteMsg) { start, complete in
       let wget = SwiftShell.run("which", "wget").stdout
        runAsync(wget,"-P", "/tmp" , "http://ipv4.download.thinkbroadband.com/20MB.zip").onCompletion { command in
            complete()
            stopWaiting()
        }
        start()
   }
}

Use one of the AeonType's to define the look and feel of the progress animation.

enum AeonType {
    case led
    case led2
    case moon
    case signal
}
aeon-bar.mov

Known duration

To show the progress bar for Tasks with known duration

print("Pac Bar".bold)
print()
        
var index = 0
        
barz(type: .pac, total: files.count) { update, complete in
    files.forEach { file in
        let  headerMessage = "Copying file ".blue.bold + TRAFIC_LIGHT + " " + file.green.bold
                
        update(index + 1, headerMessage)
                
        //Do the heavy lifting here
        
        index += 1
    }
    complete()
}

Use one of the BarType's to define the look and feel of the progress animation.

public enum BarType {
    case pac
    case pac2
    case bars
}
known-progress.mov

Suggestions

You may suggest new features. Please do so in a Pull Request.

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

Last updated: Fri Oct 18 2024 01:52:42 GMT-0900 (Hawaii-Aleutian Daylight Time)