Add progress bar to `fluent_embed_interaction`

finchie
Jun 4, 2025, 11:59 AM
BAH2JCJPTDXAE6XGSLIPBQZU4GQY65HI66Q4XTFNL65MV6VSNF2QC

Dependencies

  • [2] GJMBIJOE Migrate to latest env_preferences version
  • [3] JUV7C6ET Create initial prototype of `fluent_embed_interaction`
  • [*] VZYZRAO4 Move `output-macros` crate into workspace
  • [*] 7M4UI3TW Update dependencies to latest versions
  • [*] UKFEFT6L Create basic `Output` proc-macro
  • [*] VQBJBFEX Improve error handling for missing Fluent messages
  • [*] XGRU7WZE Add `expand` feature for proc-macro debugging

Change contents

  • replacement in fluent_embed_interaction/src/prompt/select.rs at line 36
    [3.1339][3.1339:1424]()
    let mut prompt = dialoguer::FuzzySelect::with_theme(&*crate::THEME);
    [3.1339]
    [3.1424]
    let mut prompt = dialoguer::FuzzySelect::with_theme(&*super::THEME);
  • replacement in fluent_embed_interaction/src/prompt/password.rs at line 49
    [3.3438][3.3438:3520]()
    let mut prompt = dialoguer::Password::with_theme(&*crate::THEME);
    [3.3438]
    [3.3520]
    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
    [3.7455][3.7455:7534]()
    let mut prompt = dialoguer::Input::with_theme(&*crate::THEME);
    [3.7455]
    [3.7534]
    let mut prompt = dialoguer::Input::with_theme(&*super::THEME);
  • replacement in fluent_embed_interaction/src/prompt/confirm.rs at line 19
    [3.8725][3.8725:8806]()
    let mut prompt = dialoguer::Confirm::with_theme(&*crate::THEME);
    [3.8725]
    [3.8806]
    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
    [3.9282]
    [3.9282]
    mod progress;
  • replacement in fluent_embed_interaction/src/lib.rs at line 5
    [3.9295][3.9295:9320]()
    use std::sync::LazyLock;
    [3.9295]
    [3.9320]
    use indicatif::MultiProgress;
  • replacement in fluent_embed_interaction/src/lib.rs at line 9
    [3.9367][3.9367:9386]()
    pub use prompt::*;
    [3.9367]
    [3.9386]
    pub use progress::ProgressBar;
    pub use prompt::{Confirm, Input, Password, Select};
  • edit in fluent_embed_interaction/src/lib.rs at line 12
    [3.9387][3.9387:9507]()
    static THEME: LazyLock<dialoguer::theme::ColorfulTheme> =
    LazyLock::new(dialoguer::theme::ColorfulTheme::default);
  • edit in fluent_embed_interaction/src/lib.rs at line 35
    [3.10055]
    [3.10055]
    progress_bars: MultiProgress,
  • edit in fluent_embed_interaction/src/lib.rs at line 45
    [3.10318]
    [3.10318]
    progress_bars: MultiProgress::new(),
  • edit in fluent_embed_interaction/Cargo.toml at line 13
    [3.11586]
    [3.11586]
    indicatif.workspace = true
  • edit in Cargo.toml at line 30
    [2.1312]
    [6.6380]
    indicatif = { version = "0.17.11", features = ["improved_unicode"] }
  • edit in Cargo.lock at line 84
    [8.5132]
    [8.5132]
    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
    [3.12944]
    [3.12944]
    "indicatif",
  • edit in Cargo.lock at line 810
    [8.20629]
    [8.20629]
    ]
    [[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
    [8.22031]
    [8.22031]
    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
    [8.26191]
    [8.26191]
    [[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
    [8.39478]
    [8.39478]
    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
    [3.15199]
    [3.15199]
    ]
    [[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
    [3.15214]
    [8.40906]
    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]]