Progress Bar for Command Line Tools written in Swift.
It is strongly recommended to install Nerd Fonts It may not work with regular fonts.
Dumb terminal is not supported
import PackageDescription
let package = Package(
name: "Your Package",
dependencies: [
.package(url: "https://github.com/skunkrocker/SwiftBar.git", from: "1.0.2")
]
)
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
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
You may suggest new features. Please do so in a Pull Request.