Instance Method
progressBar(title:)
Creates a new
ProgressBar-based ActivityIndicator.func progressBar(title: String) -> 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 currentProgress from 0…1
let progressBar = console.progressBar(title: "Downloading")
try await progressBar.withActivityIndicator {
while true {
if progressBar.activity.currentProgress >= 1.0 {
return
} else {
progressBar.activity.currentProgress += 0.1
try await Task.sleep(for: .seconds(0.25))
}
}
}