ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - jkandzi/Progress.swift: :hourglass: Add beautiful progress bars to your loops.
:hourglass: Add beautiful progress bars to your loops. - jkandzi/Progress.swift
Visit Site

GitHub - jkandzi/Progress.swift: :hourglass: Add beautiful progress bars to your loops.

GitHub - jkandzi/Progress.swift: :hourglass: Add beautiful progress bars to your loops.

Progress.swift :hourglass:

Build Status codecov.io Carthage compatible SPM ready Version License Platform

demo gif

Just wrap the SequenceType in your loop with the Progress SequenceType and you'll automatically get beautiful progress bars.

Updating the progress bar does not work in the Xcode console because it does not support the cursor movements. If you want it to look nice run it in a real terminal.

Example

Just take a regular loop like this for i in 1...9 { ... and wrap the 1...9 range in the Progress type and you'll automatically get a nice progress bar.

import Progress

for i in Progress(1...9) {
    ...
}

Creates this output:

$ 4 of 9 [-------------                 ] ETA: 0:00:05 (at 1.01 it/s)

It also works with all the other types adopting the CollectionType protocol like dictionarys: Progress(["key": "value", "key2": "also value"]) and arrays: Progress([1, 52, 6, 26, 1]).

You can also create the progress bar manually without a sequence type:

var bar = ProgressBar(count: 4)

for i in 0...3 {
    bar.next()
    sleep(1)
}

Configuration

You can configure the progress bar by combining single building blocks of type ProgressElementType.

Either by setting a default configuration:

ProgressBar.defaultConfiguration = [ProgressString(string: "Percent done:"), ProgressPercent()]

which creates the following result:

$ Percent done: 80%

or by providing a specific configuration in the Process initializer:

Progress(0...10, configuration: [ProgressPercent(), ProgressBarLine(barLength: 60)])

resulting in something like this:

$ 100% [------------------------------------------------------------]

Available ProgressElementType elements:

  • ProgressBarLine (The actual bar. E.g. "[---------------------- ]").
  • ProgressIndex (The current index & overall count. E.g. "2 of 3").
  • ProgressPercent (The progress in percent. E.g. "60%").
  • ProgressTimeEstimates (Estimated time remaining & items per second. E.g. "ETA: 00:00:02 (at 1.00 it/s)").
  • ProgressString (Adds an arbitrary string to the progress bar).

Installation

Cocoapods

Progress.swift is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Progress.swift"

Carthage

To integrate Progress.swift into your Xcode project using Carthage, specify it in your Cartfile:

github "jkandzi/Progress.swift"

Run carthage update to build the framework and drag the built Progress.framework into your Xcode project.

Swift Package Manager

To install with the Swift Package Manager, add the following in your Package.swift:

import PackageDescription

let package = Package(
    name: "MyProject",
    dependencies: [
        .Package(url: "https://github.com/jkandzi/Progress.swift", majorVersion: 0)
    ]
)

Manual

You can also copy the Progress.swift file into your Xcode project.

Contribution

You are welcome to fork and submit pull requests.

Author

Justus Kandzi, [email protected]

License

Progress.swift is available under the MIT license. See the LICENSE file for more info.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory