feat: add obisys crate for standardized CLI progress reporting

This commit introduces the `obisys` crate, which wraps `indicatif` to provide reusable `spinner` and `progress_bar` utilities with consistent styling and tick intervals. It refactors progress reporting across `obikindex`, `obikpartitionner`, and `obikmer` to use these shared functions, eliminating inline UI configuration and ensuring uniform terminal feedback.
This commit is contained in:
Eric Coissac
2026-06-03 15:33:15 +02:00
parent 4677d6f177
commit 02cb30c0ef
10 changed files with 59 additions and 89 deletions
+3 -2
View File
@@ -4,5 +4,6 @@ version = "0.1.0"
edition = "2024"
[dependencies]
libc = "0.2"
sysinfo = "0.33"
libc = "0.2"
sysinfo = "0.33"
indicatif = "0.17"
+33 -1
View File
@@ -1,5 +1,37 @@
use std::fmt;
use std::time::Instant;
use std::time::{Duration, Instant};
use indicatif::{ProgressBar, ProgressStyle};
const BRAILLE: &[&str] = &["", "", "", "", "", "", "", "", "", ""];
/// Spinner with the standard project look: `⠋ label — msg 0s`.
/// Caller updates the message with `pb.set_message(...)`.
pub fn spinner(label: &str) -> ProgressBar {
let pb = ProgressBar::new_spinner();
pb.set_style(
ProgressStyle::with_template(&format!("{{spinner}} {label}{{msg}} {{elapsed}}"))
.unwrap()
.tick_strings(BRAILLE),
);
pb.enable_steady_tick(Duration::from_millis(100));
pb
}
/// Progress bar with the standard project look:
/// `⠋ label — [████░░░░] pos/len unit elapsed`.
pub fn progress_bar(label: &str, n: u64, unit: &str) -> ProgressBar {
let pb = ProgressBar::new(n);
pb.set_style(
ProgressStyle::with_template(&format!(
"{{spinner}} {label}{{bar:40.cyan/blue}} {{pos}}/{{len}} {unit} {{elapsed}}"
))
.unwrap()
.tick_strings(BRAILLE),
);
pb.enable_steady_tick(Duration::from_millis(100));
pb
}
use libc::{RUSAGE_SELF, getrusage, rusage, timeval};
use sysinfo::System;