Instance Method
progressBar(title:targetQueue:)
Creates a new
ProgressBar-based ActivityIndicator.func progressBar(title: String, targetQueue: DispatchQueue? = nil) -> ActivityIndicator<ProgressBar>
Parameters
titleTitle to display alongside the loading bar.
Return Value
An ActivityIndicator that can start and stop the loading bar.
Discussion
Downloading [======== ]
The = characters represent the value of ProgressBar.currentProgress from 0…1
let progressBar = console.progressBar(title: "Downloading")
background {
// increment the progress bar by 10% every 1/4 second
// once progress is 100%, trigger success
while true {
if progressBar.activity.currentProgress >= 1 { break }
progressBar.activity.currentProgress += 0.1
console.wait(seconds: 0.25)
}
progressBar.succeed()
}
// start the progress bar and wait for it to finish
try progressBar.start(on: ...).wait()