Add progress bar to `fluent_embed_interaction`
Dependencies
- [2]
GJMBIJOEMigrate to latest env_preferences version - [3]
JUV7C6ETCreate initial prototype of `fluent_embed_interaction` - [*]
VZYZRAO4Move `output-macros` crate into workspace - [*]
7M4UI3TWUpdate dependencies to latest versions - [*]
UKFEFT6LCreate basic `Output` proc-macro - [*]
VQBJBFEXImprove error handling for missing Fluent messages - [*]
XGRU7WZEAdd `expand` feature for proc-macro debugging
Change contents
- replacement in fluent_embed_interaction/src/prompt/select.rs at line 36
let mut prompt = dialoguer::FuzzySelect::with_theme(&*crate::THEME);let mut prompt = dialoguer::FuzzySelect::with_theme(&*super::THEME); - replacement in fluent_embed_interaction/src/prompt/password.rs at line 49
let mut prompt = dialoguer::Password::with_theme(&*crate::THEME);let mut prompt = dialoguer::Password::with_theme(&*super::THEME); - edit in fluent_embed_interaction/src/prompt/mod.rs at line 11[3.4371]
use std::sync::LazyLock;static THEME: LazyLock<dialoguer::theme::ColorfulTheme> =LazyLock::new(dialoguer::theme::ColorfulTheme::default); - replacement in fluent_embed_interaction/src/prompt/input.rs at line 32
let mut prompt = dialoguer::Input::with_theme(&*crate::THEME);let mut prompt = dialoguer::Input::with_theme(&*super::THEME); - replacement in fluent_embed_interaction/src/prompt/confirm.rs at line 19
let mut prompt = dialoguer::Confirm::with_theme(&*crate::THEME);let mut prompt = dialoguer::Confirm::with_theme(&*super::THEME); - file addition: progress.rs[3.53]
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();}} - edit in fluent_embed_interaction/src/lib.rs at line 2
mod progress; - replacement in fluent_embed_interaction/src/lib.rs at line 5
use std::sync::LazyLock;use indicatif::MultiProgress; - replacement in fluent_embed_interaction/src/lib.rs at line 9
pub use prompt::*;pub use progress::ProgressBar;pub use prompt::{Confirm, Input, Password, Select}; - edit in fluent_embed_interaction/src/lib.rs at line 12
static THEME: LazyLock<dialoguer::theme::ColorfulTheme> =LazyLock::new(dialoguer::theme::ColorfulTheme::default); - edit in fluent_embed_interaction/src/lib.rs at line 35
progress_bars: MultiProgress, - edit in fluent_embed_interaction/src/lib.rs at line 45
progress_bars: MultiProgress::new(), - edit in fluent_embed_interaction/Cargo.toml at line 13
indicatif.workspace = true - edit in Cargo.toml at line 30
indicatif = { version = "0.17.11", features = ["improved_unicode"] } - edit in Cargo.lock at line 84
name = "bumpalo"version = "3.17.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"[[package]] - edit in Cargo.lock at line 376
"indicatif", - edit in Cargo.lock at line 810
][[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", - edit in Cargo.lock at line 881
name = "js-sys"version = "0.3.77"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"dependencies = ["once_cell","wasm-bindgen",][[package]] - edit in Cargo.lock at line 1054
[[package]]name = "number_prefix"version = "0.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - edit in Cargo.lock at line 1636
name = "unicode-segmentation"version = "1.12.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"[[package]] - edit in Cargo.lock at line 1694
][[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", - edit in Cargo.lock at line 1732
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]] - edit in Cargo.lock at line 1771[9.2632][9.2632]
name = "web-time"version = "1.1.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"dependencies = ["js-sys","wasm-bindgen",][[package]]