progressing-3.0.2/.cargo_vcs_info.json 0000644 00000000112 13723541234 0013474 0 ustar 00 {
"git": {
"sha1": "b4e7971f1970850f52074f355d41ebeb0d5765ff"
}
}
progressing-3.0.2/.github/workflows/rust.yml 0100644 0001751 0000164 00000004042 13723541206 0017416 0 ustar 00 0000000 0000000 name: Rust
on:
push:
pull_request:
schedule:
- cron: '0 6 * * 0-6'
jobs:
stable:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install toolchain
run: |
rustup component add rustfmt
- name: Build
run: |
cargo build --verbose
cargo build --release --verbose
- name: Run tests
run: |
cargo test --verbose
cargo fmt -- --check
- name: Build docs
run: cargo doc
beta:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install toolchain
run: |
rustup toolchain install beta
rustup default beta
- name: Build
run: |
cargo build --verbose
cargo build --release --verbose
- name: Run tests
run: |
cargo test --verbose
nightly:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
continue-on-error: true
- name: Install
run: |
rustup toolchain install nightly
rustup default nightly
continue-on-error: true
- name: Build
run: |
cargo build --verbose
cargo build --release --verbose
continue-on-error: true
- name: Run tests
run: |
cargo test --verbose
continue-on-error: true
deploy-and-tag:
if: github.ref == 'refs/heads/release'
runs-on: ubuntu-latest
needs: [stable]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup git-user
env:
GIT_USER_NAME: 'GitHub Actions'
GIT_USER_EMAIL: 'actions@users.noreply.github.com'
run: |
git config --global user.name "${GIT_USER_NAME}"
git config --global user.email "${GIT_USER_EMAIL}"
git fetch --all
- name: Deploy and tag
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
run: |
cargo build
cargo publish --token "${CRATES_TOKEN}"
git tag --annotate "v$(cargo pkgid | cut -d# -f2 | cut -d: -f2)" --message='See CHANGELOG.md'
git push --tags
progressing-3.0.2/.gitignore 0100644 0001751 0000164 00000012511 13723541206 0014271 0 ustar 00 0000000 0000000 #------------------------------------------------------------------------------#
# gitignore
# Created by https://www.gitignore.io/api/code,intellij,linux,macos,python,rust,visualstudiocode,windows
# Edit at https://www.gitignore.io/?templates=code,intellij,linux,macos,python,rust,visualstudiocode,windows
### Code ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/**/sonarlint/
# SonarQube Plugin
.idea/**/sonarIssues.xml
# Markdown Navigator plugin
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator/
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
### Rust ###
# Generated by Cargo
# will have compiled files and executables
/target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
### VisualStudioCode ###
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/code,intellij,linux,macos,python,rust,visualstudiocode,windows
#------------------------------------------------------------------------------#
# custom
/custom/
.vscode/
progressing-3.0.2/CHANGELOG.md 0100644 0001751 0000164 00000022241 13723541206 0014113 0 ustar 00 0000000 0000000 # Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog][keepachangelog], and this project adheres to [Semantic Versioning][semver].
## Table of contents
1. [Unreleased](#unreleased)
1. [v3.0.2](#v3.0.2)
1. [v3.0.1](#v3.0.1)
1. [v3.0.0](#v3.0.0)
1. [v2.2.3](#v2.2.3)
1. [v2.2.2](#v2.2.2)
1. [v2.2.1](#v2.2.1)
1. [v2.2.0](#v2.2.0)
1. [v2.1.0](#v2.1.0)
1. [v2.0.2](#v2.0.2)
1. [v2.0.1](#v2.0.1)
1. [v2.0.0](#v2.0.0)
1. [v1.0.3](#v1.0.3)
1. [v1.0.2](#v1.0.2)
## [Unreleased][github/self/unreleased]
### Added
\-
### Changed
\-
### Deprecated
\- Detailled documentation is missing, though examples are good.
### Removed
\-
### Fixed
\-
### Security
\-
## [v3.0.2][github/self/v3.0.2]
### Deprecated
- Detailled documentation is missing, though examples are good.
### Fixed
- Fix typo in README
## [v3.0.1][github/self/v3.0.1]
### Deprecated
- Detailled documentation is missing, though examples are good.
### Fixed
- Code-examples in README are being updated.
## [v3.0.0][github/self/v3.0.0]
### Added
- Add `rustfmt` to github-workflows.
- Add tests running examples (hence remove them from GitHub-workflow).
- Add wrapping `TimedBar` for approximating remaining time.
- Add printing bar dependent on relative progress (`has_progressed_significantly()` + `remember_significant_progress()`).
### Changed
- Update README.
- Cleanup `Cargo.toml`
- Make implementation much more explicit and easier by removing `reprint(...)` and refactoring `Bar`:
- Change data-types to more convenient ones (e.g. u32 -> usize).
- Implement `add(...)` based on `set(...)`
- Implement other calculations for progress to support a generic progress-calculation.
They are implemented only for some types, e.g. `usize`, `u64`, `f64`, `i64`, but new ones can be added easily.
- Implement style using a `String` (e.g. `[=>-]` -> `(#..)`)
- Hold on style-guidelines (`new()` without parameters, `with(cfg: Config)` for convenient constructors)
- Use `pub(crate)` for better control of visibility.
- Implement `timed(self)` to get a timed bar.
- Rename bars to support usage of modules explicitly (e.g. `use mapping::Bar as MappingBar` or `use progressing::mapping::Bar as ProgressingMappingBar` etc. instead of `use mapping::MappingBar` or `use progressing::MappingBar`)
### Deprecated
- Detailled documentation is missing, though examples are good.
- The README shows old code..
### Removed
- Remove `reprint(...)`-functions since they are dependent on the used writer/channel.
-> Update examples.
## [v2.2.3][github/self/v2.2.3]
### Deprecated
- Detailled documentation is missing, though examples are good.
- Bar-styles to easily and safely configure bar-styles (e.g. `[====>---]` -> `[====o---]`)
### Fixed
- Fix __badge-link__ for license in `README.md`.
## [v2.2.2][github/self/v2.2.2]
### Changed
- Change style of __LICENSE__ and write it with `markdown`.
- Replace branch `master` by `nightly`.
### Deprecated
- Detailled documentation is missing, though examples are good.
- Bar-styles to easily and safely configure bar-styles (e.g. `[====>---]` -> `[====o---]`)
## [v2.2.1][github/self/v2.2.1]
### Deprecated
- Detailled documentation is missing, though examples are good.
- Bar-styles to easily and safely configure bar-styles (e.g. `[====>---]` -> `[====o---]`)
### Fixed
- Fix URL in README.
## [v2.2.0][github/self/v2.2.0]
### Added
- Add `start(...)` and `end(...)` for `BernoulliBar` according to `MappingBar`.
### Deprecated
- Detailled documentation is missing, though examples are good.
- Bar-styles to easily and safely configure bar-styles (e.g. `[====>---]` -> `[====o---]`)
- README has wrong URL.
## [v2.1.0][github/self/v2.1.0]
### Added
- `GitHub`-workflow auto-testing and -publishing to `crates.io` if `Cargo.toml` changes version and tests are successful.
- Add a little documentation to `struct`s with little examples from `simple`-example.
- Add support for `usize` for `MappingBar`.
### Changed
- Move `structs` in own `modules`.
- Change bar-style slightly: `[====> ]` -> `[====>---]`
### Deprecated
- Detailled documentation is missing, though examples are good.
- Bar-styles to easily and safely configure bar-styles (e.g. `[====> ]` -> `[----o ]`)
## [v2.0.2][github/self/v2.0.2]
### Fixed
- `README.md` has had invalid code, which as been edited as in `examples`.
### Deprecated
- Detailled documentation is missing, though examples are good.
- Bar-styles to easily and safely configure bar-styles (e.g. `[====> ]` -> `[----o ]`)
## [v2.0.1][github/self/v2.0.1]
### Changed
- Changelog has been edited accordingly.
### Deprecated
- Detailled documentation is missing, though examples are good.
- Bar-styles to easily and safely configure bar-styles (e.g. `[====> ]` -> `[----o ]`)
## [v2.0.0][github/self/v2.0.0]
### Added
- Add access to a bar's `progress`.
- Extend `BernoulliProgress`
- Implement some useful traits like `Add` and `Copy`.
- Implement automatic `into()` for tuples (`(successes, attempts)`) or successes (`u32` or `bool`).
- Implement constructing method `new()` and `Default`.
### Changed
- `ID`s in `CHANGELOG.md` since underscores (`_`) are preferred over dots (`.`) in `URL`s, but `v1103` could stand for `v11.0.3` and `v1.10.3`.
### Deprecated
- Detailled documentation is missing, though examples are good.
- Bar-styles to easily and safely configure bar-styles (e.g. `[====> ]` -> `[----o ]`)
- Changelog has been forgotten to adapt..
## [v1.0.3][github/self/v1.0.3]
### Added
- Implement `CHANGELOG.md`
### Deprecated
- `BernoulliProgress` has no constructing method like `new()` and no default-implementation.
- Detailled documentation is missing, though examples are good.
## [v1.0.2][github/self/v1.0.2]
### Added
- Setup repo with license, readme, .gitignore etc.
- Add nice `examples`.
- Implement 3 different `progressbars` and let them accept values outside of their intervals.
- One is clamping `float`s to `[0, 1]`.
- One is counting and mapping `i32` or `u32` from `[a, b]` to `[0, 1]`.
- One is counting successes and attempts for a given goal `n`.
- Change a bar's progress via methods `set` and `add` using
- `BernoulliProgress` (which is `pub`)- Support for `GitHub-workflow` is missing, which can, besides testing, automatically deploy to `crates.io` and tag if `Cargo.toml` changes version.
- `CHANGELOG.md` is missing
- `BernoulliProgress` has no constructing method like `new()` and no default-implementation.
- Detailled documentation is missing, though examples are good.
[keepachangelog]: https://keepachangelog.com/en/
[semver]: https://semver.org/
[github/self/unreleased]: https://github.com/dominicparga/progressing/compare/v3.0.2...HEAD
[github/self/v3.0.2]: https://github.com/dominicparga/progressing/compare/v3.0.1...v3.0.2
[github/self/v3.0.1]: https://github.com/dominicparga/progressing/compare/v3.0.0...v3.0.1
[github/self/v3.0.0]: https://github.com/dominicparga/progressing/compare/v2.2.2...v3.0.0
[github/self/v2.2.2]: https://github.com/dominicparga/progressing/compare/v2.2.1...v2.2.2
[github/self/v2.2.1]: https://github.com/dominicparga/progressing/compare/v2.2.0...v2.2.1
[github/self/v2.2.0]: https://github.com/dominicparga/progressing/compare/v2.1.0...v2.2.0
[github/self/v2.1.0]: https://github.com/dominicparga/progressing/compare/v2.0.2...v2.1.0
[github/self/v2.0.2]: https://github.com/dominicparga/progressing/compare/v2.0.1...v2.0.2
[github/self/v2.0.1]: https://github.com/dominicparga/progressing/compare/v2.0.0...v2.0.1
[github/self/v2.0.0]: https://github.com/dominicparga/progressing/compare/v1.0.3...v2.0.0
[github/self/v1.0.3]: https://github.com/dominicparga/progressing/compare/v1.0.2...v1.0.3
[github/self/v1.0.2]: https://github.com/dominicparga/progressing/releases/tag/v1.0.2
progressing-3.0.2/Cargo.lock 0000644 00000001102 13723541234 0011447 0 ustar 00 # This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "log"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
dependencies = [
"cfg-if",
]
[[package]]
name = "progressing"
version = "3.0.2"
dependencies = [
"log",
]
progressing-3.0.2/Cargo.toml 0000644 00000002100 13723541234 0011471 0 ustar 00 # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
[package]
edition = "2018"
name = "progressing"
version = "3.0.2"
authors = ["Parga Cacheiro, Dominic (dominic.parga@gmail.com)"]
description = "A lightweight, text-based, counting progress-bar for Rust"
readme = "README.md"
keywords = ["progressbar", "progress", "pbr", "logging", "counting"]
categories = ["command-line-interface"]
license = "Apache-2.0"
repository = "https://github.com/dominicparga/progressing"
[[example]]
name = "simple"
path = "examples/simple.rs"
[[example]]
name = "loops"
path = "examples/loops.rs"
[dependencies.log]
version = "0.4"
progressing-3.0.2/Cargo.toml.orig 0100644 0001751 0000164 00000001563 13723541206 0015175 0 ustar 00 0000000 0000000 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[package]
name = 'progressing'
# Changing this version in release and pushing to GitHub
# will lead to publishing it automatically to crates.io.
# Hence do not forget updating Unreleased in CHANGELOG.md.
version = '3.0.2' # !!!
description = 'A lightweight, text-based, counting progress-bar for Rust'
edition = '2018'
authors = [
'Parga Cacheiro, Dominic (dominic.parga@gmail.com)',
]
repository = 'https://github.com/dominicparga/progressing'
readme = 'README.md'
keywords = ['progressbar', 'progress', 'pbr', 'logging', 'counting']
categories = ['command-line-interface']
license = 'Apache-2.0'
[[example]]
name = 'simple'
path = 'examples/simple.rs'
[[example]]
name = 'loops'
path = 'examples/loops.rs'
[dependencies]
log = '0.4' # logging for internal use, e.g. lib.rs
progressing-3.0.2/LICENSE.md 0100644 0001751 0000164 00000003012 13723541206 0013701 0 ustar 00 0000000 0000000 # License and Copyright
This repository and its content are licensed under the Apache License, Version 2.0 (the "License").
You may not use content of this repository or its files except in compliance with the License.
You may obtain a copy of the License at
`http://www.apache.org/licenses/LICENSE-2.0`
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
## Mentioning this Copyright in own projects
Please include this Copyright- and License-notice in your project.
As suggested in the License, you may choose a separate file like "NOTICE" for this.
Instead of copying the whole notice, you may copy only the following short version.
```text
progressing
https://github.com/dominicparga/progressing
Copyright 2020 Dominic Parga Cacheiro
License Apache-2.0
```
## Short description of some content
This repository "progressing" is a lightweight, text-based, counting progress-bar for Rust.
## Dependencies
```text
clap
https://github.com/clap-rs/clap
Copyright (c) 2015-2016 Kevin B. Knapp
License MIT AND Apache-2.0
```
```text
env_logger
https://github.com/sebasmagri/env_logger
Copyright (c) 2014 The Rust Project Developers
License MIT/Apache-2.0
```
```text
log
https://github.com/rust-lang/log
Copyright (c) 2014 The Rust Project Developers
License MIT OR Apache-2.0
```
progressing-3.0.2/README.md 0100644 0001751 0000164 00000013141 13723541206 0013560 0 ustar 00 0000000 0000000 # progressing
[![Build Status nightly][github/self/actions/badge]][github/self/actions]
[![Tag][github/self/tags/badge]][github/self/tags]
[![Crates.io][crates.io/self/badge]][crates.io/self]
[![Docs][docs.rs/self/badge]][docs.rs/self]
[![Changelog][github/self/blob/changelog/badge]][github/self/blob/changelog]
[![Last commit][github/self/last-commit/badge]][github/self/last-commit]
[![License][github/self/license/badge]][github/self/license]
## Look and feel
At first, the trait `Baring` is needed.
```rust
use progressing::{
// The underlying Trait
Baring,
// Just handy names for the examples below
bernoulli::Bar as BernoulliBar,
clamping::Bar as ClampingBar,
mapping::Bar as MappingBar,
};
```
In the following, different use-cases of the provided progress-bars are presented.
Note, that the examples below use `set(...)`, but `add(...)` is supported as well.
- Printing value `0.3` clamped to `[0, 1]` prints `[=====>------------]`.
```rust
let mut progress_bar = ClampingBar::new();
progress_bar.set_len(20);
progress_bar.set(0.3);
println!("{}", progress_bar);
```
- Printing value `4` mapped from `[-9, 5]` to `[0, 1]` prints `[================>-] (4 / 5)`.
```rust
let mut progress_bar = MappingBar::with_range(-9, 5);
progress_bar.set_len(20);
progress_bar.set(4);
println!("{}", progress_bar);
```
- Every bar can be used with a simple time-approximation based on the past process.
For a process of this duration, this example would print `[================>-] (4 / 5) ~ 2 min`.
The only difference is the call of `timed()`.
```rust
let mut progress_bar = MappingBar::with_range(-9, 5).timed();
progress_bar.set_len(20);
progress_bar.set(4);
println!("{}", progress_bar);
```
- In case something should be counted and failures may occur, try this example.
When counting `42` successes, where `60` is the goal and `130` attempts have been made, `[============>-----] (42 / 60 # 130)` is printed.
Adding trials may be handier using `bool`s.
```rust
let mut progress_bar = BernoulliBar::from_goal(60);
progress_bar.set_len(20);
progress_bar.set((42, 130));
println!("{}", progress_bar);
let is_successful = true;
if is_successful {
// Does increase both 42 and 130
progress_bar.add(true);
} else {
// Does increase 130 only
progress_bar.add(false);
}
```
- You may change a bar's style by setting it to a string of `5` characters.
```rust
let mut progress_bar = ClampingBar::new();
progress_bar.set_len(20);
progress_bar.set(0.3);
// different custom styles are possible
// prints (----->............)
progress_bar.set_style("(->.)");
println!("{}", progress_bar);
// prints [##### ]
progress_bar.set_style("[# ]");
println!("{}", progress_bar);
// prints (#####-------------)
progress_bar.set_style("(#--)");
println!("{}", progress_bar);
```
- Another typical use-case may be printing some, not every progress in a loop.
```rust
let mut progress_bar = BernoulliBar::with_goal(100).timed();
progress_bar.set_len(20);
progress_bar.set(13);
// do the job and show progress
for _ in 0..100 {
progress_bar.add(true);
if progress_bar.has_progressed_significantly() {
progress_bar.remember_significant_progress();
println!("{}", progress_bar);
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
println!("{}", progress_bar);
```
will print
```text
[=>................] (10/100) #14 ~8s
[===>..............] (20/100) #20 ~7s
[=====>............] (30/100) #30 ~6s
[=======>..........] (40/100) #40 ~5s
[=========>........] (50/100) #50 ~4s
[==========>.......] (60/100) #60 ~3s
[============>.....] (70/100) #70 ~2s
[==============>...] (80/100) #80 ~1s
[================>.] (90/100) #90 ~0s
[==================] (100/100) #100 ~0s
[==================] (100/100) #113 ~0s
```
A line is printed every time when another `10 %` of the goal is reached.
Please note, that the progress-bar starts with `13` and hence needs `113` attempts in total.
## Setup and usage
Just add `progressing = '3'` to the dependencies in `Cargo.toml`.
Please refer to the [examples][github/self/tree/examples] for some more examples.
[crates.io/self]: https://crates.io/crates/progressing
[crates.io/self/badge]: https://img.shields.io/crates/v/progressing?style=for-the-badge
[docs.rs/self]: https://docs.rs/progressing/
[docs.rs/self/badge]: https://img.shields.io/crates/v/progressing?color=informational&label=docs&style=for-the-badge
[github/self/actions]: https://github.com/dominicparga/progressing/actions
[github/self/actions/badge]: https://img.shields.io/github/workflow/status/dominicparga/progressing/Rust?label=nightly-build&style=for-the-badge
[github/self/blob/changelog]: https://github.com/dominicparga/progressing/blob/nightly/CHANGELOG.md
[github/self/blob/changelog/badge]: https://img.shields.io/badge/CHANGELOG-nightly-blueviolet?style=for-the-badge
[github/self/last-commit]: https://github.com/dominicparga/progressing/commits
[github/self/last-commit/badge]: https://img.shields.io/github/last-commit/dominicparga/progressing?style=for-the-badge
[github/self/license]: https://github.com/dominicparga/progressing/blob/nightly/LICENSE.md
[github/self/license/badge]: https://img.shields.io/badge/LICENSE-Apache--2.0-green?style=for-the-badge
[github/self/tags]: https://github.com/dominicparga/progressing/tags
[github/self/tags/badge]: https://img.shields.io/github/v/tag/dominicparga/progressing?sort=semver&style=for-the-badge
[github/self/tree/examples]: https://github.com/dominicparga/progressing/tree/nightly/examples
progressing-3.0.2/examples/loops.rs 0100644 0001751 0000164 00000006246 13723541206 0015631 0 ustar 00 0000000 0000000 use progressing::{
bernoulli::Bar as BernoulliBar, clamping::Bar as ClampingBar, mapping::Bar as MappingBar,
Baring,
};
use std::{thread, time};
const SLEEP_MS: u64 = 20;
fn main() {
// different examples for different use-cases
clamped();
println!();
mapped();
println!();
bernoulli();
}
fn clamped() {
let min_value = -80;
let max_value = 180;
println!(
"The bar is running from {} % to {} % clamping to [0, 1].",
min_value, max_value
);
println!(
"{}{}",
"Note the respective pause at the beginning and the end, ",
"which causes the approximated time to be too high."
);
// create bar
let mut progress_bar = ClampingBar::new().timed();
// do the job and show progress
for value in min_value..(max_value + 1) {
progress_bar.set(value as f32 / 100.0);
if progress_bar.has_progressed_significantly() {
progress_bar.remember_significant_progress();
println!("{}", progress_bar);
}
// sleep for visual effects ;)
thread::sleep(time::Duration::from_millis(SLEEP_MS));
}
// add new line to finished progress-bar
println!("{}", progress_bar);
}
fn mapped() {
let min_value = -10;
let max_value = 100;
let min_bar_border = -40;
let max_bar_border = 140;
println!(
"The bar is running from {} to {}, but maps [{}, {}] to [0, 1].",
min_value, max_value, min_bar_border, max_bar_border
);
println!("Note that the bar neither starts nor ends at the bar-borders.");
// create bar
let mut progress_bar = MappingBar::with_range(min_bar_border, max_bar_border).timed();
// do the job and show progress
for value in min_value..(max_value + 1) {
progress_bar.set(value);
if progress_bar.has_progressed_significantly() {
progress_bar.remember_significant_progress();
println!("{}", progress_bar);
}
// sleep for visual effects ;)
thread::sleep(time::Duration::from_millis(SLEEP_MS));
}
// add new line to finished progress-bar
println!("{}", progress_bar);
}
fn bernoulli() {
let min_value = -50;
let max_value = 120;
println!(
"The bar is running from {} to {} counting successes (if value is even) and attempts ({}).",
min_value,
max_value,
(max_value - min_value) + 1
);
println!("Note that the bar expects less successes than provided .");
// create bar
let mut progress_bar = BernoulliBar::with_goal(60).timed();
// you can reset the length of it
progress_bar.set_len(60);
// do the job and show progress
for value in min_value..(max_value + 1) {
// job is successful if value is even
let is_successful = value % 2 == 0;
progress_bar.add(is_successful);
if progress_bar.has_progressed_significantly() {
progress_bar.remember_significant_progress();
println!("{}", progress_bar);
}
// sleep for visual effects ;)
thread::sleep(time::Duration::from_millis(SLEEP_MS));
}
// add new line to finished progress-bar
println!("{}", progress_bar);
}
progressing-3.0.2/examples/simple.rs 0100644 0001751 0000164 00000005722 13723541206 0015764 0 ustar 00 0000000 0000000 use progressing::{
bernoulli::Bar as BernoulliBar, clamping::Bar as ClampingBar, mapping::Bar as MappingBar,
Baring,
};
fn main() {
// different examples for different use-cases
clamped();
println!();
mapped();
println!();
timed_mapped();
println!();
bernoulli();
println!();
styles();
println!();
remember_progress();
}
/// Printing value 0.3 clamped to [0, 1]
/// [=====>------------]
fn clamped() {
println!("Printing value 0.3 clamped to [0, 1]");
let mut progress_bar = ClampingBar::new();
progress_bar.set_len(20);
progress_bar.set(0.3);
println!("{}", progress_bar);
}
/// Mapping from [-9, 5] to [0, 1]
/// [================>-] (4 / 5)
fn mapped() {
println!("Mapping from [-9, 5] to [0, 1]");
let mut progress_bar = MappingBar::with_range(-9, 5);
progress_bar.set_len(20);
progress_bar.set(4);
println!("{}", progress_bar);
}
/// Mapping from [-9, 5] to [0, 1], but with time-approximation
/// [================>-] (4 / 5) ~ 2 min
fn timed_mapped() {
println!("Mapping from [-9, 5] to [0, 1], but with time-approximation");
let mut progress_bar = MappingBar::with_range(-9, 5).timed();
progress_bar.set_len(20);
progress_bar.set(4);
println!("{}", progress_bar);
}
/// Bernoulli-Bar counting successes (42 / 60) and attempts (# 130)
/// [============>-----] (42 / 60 # 130)
fn bernoulli() {
println!("Bernoulli-Bar counting successes (42 / 60) and attempts (# 130)");
let mut progress_bar = BernoulliBar::with_goal(60);
progress_bar.set_len(20);
progress_bar.set((42, 130));
progress_bar.add(true);
println!("{}", progress_bar);
let is_successful = true;
if is_successful {
// Does increase both 42 and 130
progress_bar.add(true);
} else {
// Does increase 130 only
progress_bar.add(false);
}
}
/// clamped-example, but with other styles
fn styles() {
println!("Custom styles");
let mut progress_bar = ClampingBar::new();
progress_bar.set_len(20);
progress_bar.set(0.3);
// different custom styles are possible
// prints (----->............)
progress_bar.set_style("(->.)");
println!("{}", progress_bar);
// prints [##### ]
progress_bar.set_style("[# ]");
println!("{}", progress_bar);
// prints [#####-------------]
progress_bar.set_style("(#--)");
println!("{}", progress_bar);
}
fn remember_progress() {
println!("Looped progress");
// create bar
let mut progress_bar = BernoulliBar::with_goal(100).timed();
progress_bar.set_len(20);
progress_bar.set(13);
// do the job and show progress
for _ in 0..100 {
progress_bar.add(true);
if progress_bar.has_progressed_significantly() {
progress_bar.remember_significant_progress();
println!("{}", progress_bar);
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
println!("{}", progress_bar);
}
progressing-3.0.2/scripts/echo_gitignore.sh 0100755 0001751 0000164 00000001077 13723541206 0017321 0 ustar 00 0000000 0000000 #!/usr/bin/env sh
#------------------------------------------------------------------------------#
# notes
# This file uses gitignore.io, which uses CRLF.
# To replace them by LF, you can use dos2unix
echo '#------------------------------------------------------------------------------#'
echo '# gitignore'
curl -L -s 'https://www.gitignore.io/api/code,intellij,linux,macos,python,rust,visualstudiocode,windows'
echo ''
echo '#------------------------------------------------------------------------------#'
echo '# custom'
echo ''
echo '/custom/'
echo ''
echo '.vscode/'
progressing-3.0.2/src/bernoulli.rs 0100644 0001751 0000164 00000007321 13723541206 0015434 0 ustar 00 0000000 0000000 use crate::{mapping, timing, Baring};
use std::{
fmt::{self, Display},
ops::{Add, AddAssign, Div, Sub},
};
pub struct Config {}
/// A progress-bar counting successes (e.g. `42 out of 60`) and respective attempts (e.g. `130`).
///
/// # Mini-Example
///
/// ```
/// use progressing::{Baring, bernoulli::Bar as BernoulliBar};
///
/// /// Bernoulli-Bar counting successes (42 / 60) and attempts (# 130)
/// /// [============>-----] (42 / 60 # 130)
/// fn main() {
/// println!("Bernoulli-Bar counting successes (42 / 60) and attempts (# 130)");
/// let mut progress_bar = BernoulliBar::with_goal(60);
/// progress_bar.set_len(20);
/// progress_bar.set((42, 130));
/// println!("{}", progress_bar);
/// }
/// ```
#[derive(Debug)]
pub struct Bar {
bar: mapping::Bar,
attempts: usize,
}
impl Bar {
pub fn with_goal(end: usize) -> Bar {
Bar {
bar: mapping::Bar::with_range(0, end),
attempts: 0,
}
}
pub fn timed(self) -> timing::Bar {
timing::Bar::with(self)
}
}
impl Baring for Bar {
type Progress = Progress;
fn len(&self) -> usize {
self.bar.len()
}
fn set_len(&mut self, new_bar_len: usize) {
self.bar.set_len(new_bar_len)
}
fn progress(&self) -> Progress {
Progress {
successes: self.bar.progress(),
attempts: self.attempts,
}
}
fn set