https://github.com/consoletvs/procedure
Procedure allows to execute tasks with a visual indication to the end user in the stdout.
https://github.com/consoletvs/procedure
Last synced: 9 months ago
JSON representation
Procedure allows to execute tasks with a visual indication to the end user in the stdout.
- Host: GitHub
- URL: https://github.com/consoletvs/procedure
- Owner: ConsoleTVs
- License: mit
- Created: 2019-11-11T15:51:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-06T14:14:22.000Z (over 6 years ago)
- Last Synced: 2025-08-18T21:03:24.644Z (10 months ago)
- Language: Rust
- Size: 7.81 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Procedure
Procedure allows to execute tasks with a visual indication to the end user in the stdout.
This is inteted to be used as a command line display.

## Features
- Padded action display (like the rust compiler / cargo).
- Colored output (Yello = Running, Green = Succeed, Red = Failed).
- Provide a description for the task.
- Percentage progress indication at your need (updates on the screen).
## Samples
```rust
let a = proceed("Download", "example_file.jpg", |progress: &mut Progress| -> Result<(&str, &str), &str> {
for _ in 0..100 {
std::thread::sleep(std::time::Duration::from_millis(10));
progress.increment(1);
}
Ok(("256KB", "example_file.jpg [256 KB]"))
});
assert_eq!(a.unwrap(), "256KB");
let b = proceed("Download", "some_other.zip", |progress: &mut Progress| -> Result<(&str, &str), &str> {
let min = 500;
let max = 1000;
for i in min..max {
std::thread::sleep(std::time::Duration::from_millis(5));
progress.set_from(min, max, i);
if i == 975 {
return Err("some_other.zip [Failed]");
}
}
Ok(("1MB", "some_other.zip [1 MB]"))
});
assert_eq!(b.unwrap_err(), "some_other.zip [Failed]");
```