For now, trying to avoid spinners as it should be theoretically possible to integrate these into Pijul without them
BAH2JCJPTDXAE6XGSLIPBQZU4GQY65HI66Q4XTFNL65MV6VSNF2QC
GJMBIJOE47X7DKZDHIY6VQ2ISC52XAVAV46L6PJQZTV7L7DDSWOAC
JUV7C6ET4ZQJNLO7B4JB7XMLV2YUBZB4ARJHN4JEPHDGGBWGLEVAC
7M4UI3TWQIAA333GQ577HDWDWZPSZKWCYG556L6SBRLB6SZDQYPAC
VZYZRAO4EXCHW2LBVFG5ELSWG5SCNDREMJ6RKQ4EKQGI2T7SD3ZQC
VQBJBFEXRTJDBH27SVWRBCBFC7OOFOZ3DSMX7PE5BIZQLGHPVDYAC
UKFEFT6LSI4K7X6UHQFZYD52DILKXMZMYSO2UYS2FCHNPXIF4BEQC
XGRU7WZEM6PTUCSHUA6QGNK7N34M7OPE52BTDC33BHSUEWM6B4FAC
use std::sync::LazyLock;
static THEME: LazyLock<dialoguer::theme::ColorfulTheme> =
LazyLock::new(dialoguer::theme::ColorfulTheme::default);
use crate::InteractionEnvironment;
use fluent_embed::{LocalizationError, Localize};
use indicatif::ProgressStyle;
use std::sync::LazyLock;
static PROGRESS_TEMPLATE: LazyLock<ProgressStyle> = LazyLock::new(|| {
ProgressStyle::with_template("{msg:<20} [{bar:50}] {pos}/{len} [{elapsed_precise}]")
.unwrap()
.progress_chars("=> ")
});
pub struct ProgressBar {
progress_bar: indicatif::ProgressBar,
}
impl ProgressBar {
pub fn new(environment: &InteractionEnvironment, length: u64) -> Self {
Self {
progress_bar: environment
.progress_bars
.add(indicatif::ProgressBar::new(length).with_style(PROGRESS_TEMPLATE.clone())),
}
}
pub fn with_message<L: Localize>(mut self, message: L) -> Result<Self, LocalizationError> {
let mut buffer = Vec::new();
message.localize(&mut buffer)?;
let localized_text = String::from_utf8(buffer)?;
self.progress_bar = self.progress_bar.with_message(localized_text);
Ok(self)
}
pub fn increment(&self, delta: u64) {
self.progress_bar.inc(delta);
}
pub fn finish(self) {
self.progress_bar.finish();
}
}
]
[[package]]
name = "indicatif"
version = "0.17.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235"
dependencies = [
"console",
"number_prefix",
"portable-atomic",
"unicode-segmentation",
"unicode-width 0.2.0",
"web-time",
]
[[package]]
name = "wasm-bindgen"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
dependencies = [
"cfg-if",
"once_cell",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
dependencies = [
"bumpalo",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
name = "wasm-bindgen-macro-support"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
dependencies = [
"unicode-ident",
]
[[package]]