Move prompt message to initial constructor

finchie
Aug 8, 2025, 7:00 AM
IZ67IMRIPBOYLOAR5WE5NYA7MHOT7TXXEE7WM63MU4JSH6OM7YQQC

Dependencies

  • [2] EKXWNEPK Rename `Localize::message_for_locale` to `Localize::localize_for`
  • [3] BAH2JCJP Add progress bar to `fluent_embed_interaction`
  • [4] U2PHMYPD Return `String` directly instead of writing to buffer in `Localize::localize`
  • [5] 3BUFFCHQ Return `Option<T>` instead of `T` from `interact()`
  • [6] QJC4IQIT Refactor `Localize` functions to infallibly return `String`
  • [7] RUCC2HKZ Rename from `fluent_embed` to `l10n_embed`
  • [8] NEBSVXIA Apply Clippy fixes
  • [9] 7YOM2QEF Move interaction constructors from individual types to implementations on `InteractionEnvironment`
  • [10] JUV7C6ET Create initial prototype of `fluent_embed_interaction`

Change contents

  • replacement in l10n_embed_interaction/src/prompt/select.rs at line 1
    [3.109][3.16:74]()
    use super::macros::{impl_with_default, impl_with_prompt};
    [3.109]
    [3.0]
    use super::macros::impl_with_default;
  • edit in l10n_embed_interaction/src/prompt/select.rs at line 7
    [3.164]
    [3.347]
    localized_prompt: String,
  • edit in l10n_embed_interaction/src/prompt/select.rs at line 10
    [3.407][3.407:435]()
    prompt: Option<String>,
  • edit in l10n_embed_interaction/src/prompt/select.rs at line 13
    [3.492][3.492:519]()
    impl_with_prompt!(Select);
  • replacement in l10n_embed_interaction/src/prompt/select.rs at line 15
    [3.207][3.207:307]()
    pub(crate) fn new_from_environment(environment: &'environment InteractionEnvironment) -> Self {
    [3.207]
    [3.307]
    pub(crate) fn new_from_environment<L: Localize>(
    environment: &'environment InteractionEnvironment,
    prompt: L,
    ) -> Self {
    let localized_prompt = prompt.localize_for(&environment.locale);
  • edit in l10n_embed_interaction/src/prompt/select.rs at line 23
    [3.347]
    [3.347]
    localized_prompt,
  • edit in l10n_embed_interaction/src/prompt/select.rs at line 26
    [3.399][3.399:425]()
    prompt: None,
  • replacement in l10n_embed_interaction/src/prompt/select.rs at line 42
    [3.1339][3.0:85]()
    let mut prompt = dialoguer::FuzzySelect::with_theme(&*super::THEME);
    [3.1339]
    [3.1424]
    let mut prompt = dialoguer::FuzzySelect::with_theme(&*super::THEME)
    .with_prompt(self.localized_prompt);
  • edit in l10n_embed_interaction/src/prompt/select.rs at line 53
    [3.1672][3.1672:1810]()
    if let Some(prompt_text) = self.prompt {
    prompt = prompt.with_prompt(prompt_text);
    }
  • replacement in l10n_embed_interaction/src/prompt/password.rs at line 1
    [3.2012][3.632:692]()
    use super::macros::{impl_with_prompt, impl_with_validator};
    [3.2012]
    [3.303]
    use super::macros::impl_with_validator;
  • replacement in l10n_embed_interaction/src/prompt/password.rs at line 6
    [3.2243][3.2243:2263]()
    prompt: String,
    [3.2243]
    [3.2263]
    localized_prompt: String,
  • edit in l10n_embed_interaction/src/prompt/password.rs at line 12
    [3.784]
    [3.2335]
    prompt: String,
  • edit in l10n_embed_interaction/src/prompt/password.rs at line 14
    [3.2383][3.2383:2411]()
    prompt: Option<String>,
  • edit in l10n_embed_interaction/src/prompt/password.rs at line 17
    [3.2502][3.2502:2531]()
    impl_with_prompt!(Password);
  • replacement in l10n_embed_interaction/src/prompt/password.rs at line 20
    [3.829][3.829:929]()
    pub(crate) fn new_from_environment(environment: &'environment InteractionEnvironment) -> Self {
    [3.829]
    [3.929]
    pub(crate) fn new_from_environment<L: Localize>(
    environment: &'environment InteractionEnvironment,
    prompt: L,
    ) -> Self {
    let localized_prompt = prompt.localize_for(&environment.locale);
  • edit in l10n_embed_interaction/src/prompt/password.rs at line 28
    [3.969]
    [3.969]
    prompt: localized_prompt,
  • edit in l10n_embed_interaction/src/prompt/password.rs at line 30
    [3.1001][3.1001:1027]()
    prompt: None,
  • replacement in l10n_embed_interaction/src/prompt/password.rs at line 43
    [3.3099][3.3099:3138]()
    prompt: confirmation_text,
    [3.3099]
    [3.3138]
    localized_prompt: confirmation_text,
  • replacement in l10n_embed_interaction/src/prompt/password.rs at line 53
    [3.3438][3.86:168]()
    let mut prompt = dialoguer::Password::with_theme(&*super::THEME);
    [3.3438]
    [3.3520]
    let mut prompt =
    dialoguer::Password::with_theme(&*super::THEME).with_prompt(self.prompt);
  • replacement in l10n_embed_interaction/src/prompt/password.rs at line 57
    [3.3585][3.3585:3714]()
    prompt =
    prompt.with_confirmation(confirmation.prompt, confirmation.mismatch_error);
    [3.3585]
    [3.3714]
    prompt = prompt.with_confirmation(
    confirmation.localized_prompt,
    confirmation.mismatch_error,
    );
  • edit in l10n_embed_interaction/src/prompt/password.rs at line 63
    [3.3733][3.3733:3871]()
    if let Some(prompt_text) = self.prompt {
    prompt = prompt.with_prompt(prompt_text);
    }
  • edit in l10n_embed_interaction/src/prompt/macros.rs at line 12
    [3.4855][3.4855:4914](),[3.4914][3.1532:1584](),[3.1584][3.88:175](),[3.4938][3.88:175](),[3.175][2.245:329](),[3.216][3.5244:5296](),[2.329][3.5244:5296](),[3.475][3.5244:5296](),[3.1675][3.5244:5296](),[3.5244][3.5244:5296]()
    macro_rules! impl_with_prompt {
    ($newtype:ident) => {
    impl<'environment> $newtype<'environment> {
    pub fn with_prompt<L: l10n_embed::Localize>(mut self, prompt: L) -> Self {
    let localized_text = prompt.localize_for(&self.environment.locale);
    self.prompt = Some(localized_text);
  • edit in l10n_embed_interaction/src/prompt/macros.rs at line 13
    [3.5297][3.476:497](),[3.497][3.5322:5356](),[3.5322][3.5322:5356]()
    self
    }
    }
    };
    }
  • replacement in l10n_embed_interaction/src/prompt/macros.rs at line 41
    [3.6369][3.1862:1937]()
    pub(crate) use {impl_with_default, impl_with_prompt, impl_with_validator};
    [3.6369]
    pub(crate) use {impl_with_default, impl_with_validator};
  • replacement in l10n_embed_interaction/src/prompt/input.rs at line 1
    [3.6488][3.1938:1998]()
    use super::macros::{impl_with_prompt, impl_with_validator};
    [3.6488]
    [3.526]
    use super::macros::impl_with_validator;
  • edit in l10n_embed_interaction/src/prompt/input.rs at line 7
    [3.2087]
    [3.6727]
    localized_prompt: String,
  • edit in l10n_embed_interaction/src/prompt/input.rs at line 9
    [3.6756][3.6756:6784]()
    prompt: Option<String>,
  • edit in l10n_embed_interaction/src/prompt/input.rs at line 12
    [3.6872][3.6872:6898]()
    impl_with_prompt!(Input);
  • replacement in l10n_embed_interaction/src/prompt/input.rs at line 15
    [3.2129][3.2129:2229]()
    pub(crate) fn new_from_environment(environment: &'environment InteractionEnvironment) -> Self {
    [3.2129]
    [3.2229]
    pub(crate) fn new_from_environment<L: Localize>(
    environment: &'environment InteractionEnvironment,
    prompt: L,
    ) -> Self {
    let localized_prompt = prompt.localize_for(&environment.locale);
  • edit in l10n_embed_interaction/src/prompt/input.rs at line 23
    [3.2269]
    [3.2269]
    localized_prompt,
  • edit in l10n_embed_interaction/src/prompt/input.rs at line 25
    [3.2296][3.2296:2322]()
    prompt: None,
  • replacement in l10n_embed_interaction/src/prompt/input.rs at line 39
    [3.7455][3.315:394]()
    let mut prompt = dialoguer::Input::with_theme(&*super::THEME);
    [3.7455]
    [3.7534]
    let mut prompt =
    dialoguer::Input::with_theme(&*super::THEME).with_prompt(self.localized_prompt);
  • edit in l10n_embed_interaction/src/prompt/input.rs at line 46
    [3.7662][3.7662:7800]()
    if let Some(prompt_text) = self.prompt {
    prompt = prompt.with_prompt(prompt_text);
    }
  • replacement in l10n_embed_interaction/src/prompt/confirm.rs at line 1
    [3.8140][3.2567:2625]()
    use super::macros::{impl_with_default, impl_with_prompt};
    [3.8140]
    [3.749]
    use super::macros::impl_with_default;
  • edit in l10n_embed_interaction/src/prompt/confirm.rs at line 3
    [3.804]
    [3.8338]
    use l10n_embed::Localize;
  • edit in l10n_embed_interaction/src/prompt/confirm.rs at line 8
    [3.2716]
    [3.8379]
    localized_prompt: String,
  • edit in l10n_embed_interaction/src/prompt/confirm.rs at line 10
    [3.8406][3.8406:8434]()
    prompt: Option<String>,
  • edit in l10n_embed_interaction/src/prompt/confirm.rs at line 13
    [3.8492][3.8492:8520]()
    impl_with_prompt!(Confirm);
  • replacement in l10n_embed_interaction/src/prompt/confirm.rs at line 15
    [3.2760][3.2760:2860]()
    pub(crate) fn new_from_environment(environment: &'environment InteractionEnvironment) -> Self {
    [3.2760]
    [3.2860]
    pub(crate) fn new_from_environment<L: Localize>(
    environment: &'environment InteractionEnvironment,
    prompt: L,
    ) -> Self {
    let localized_prompt = prompt.localize_for(&environment.locale);
  • edit in l10n_embed_interaction/src/prompt/confirm.rs at line 23
    [3.2900]
    [3.2900]
    localized_prompt,
  • edit in l10n_embed_interaction/src/prompt/confirm.rs at line 25
    [3.2927][3.2927:2953]()
    prompt: None,
  • replacement in l10n_embed_interaction/src/prompt/confirm.rs at line 31
    [3.8725][3.395:476]()
    let mut prompt = dialoguer::Confirm::with_theme(&*super::THEME);
    [3.8725]
    [3.8806]
    let mut confirm = dialoguer::Confirm::with_theme(&*super::THEME)
    .with_prompt(self.localized_prompt);
  • replacement in l10n_embed_interaction/src/prompt/confirm.rs at line 35
    [3.8861][3.8861:8915]()
    prompt = prompt.default(default);
    [3.8861]
    [3.8915]
    confirm = confirm.default(default);
  • replacement in l10n_embed_interaction/src/prompt/confirm.rs at line 38
    [3.8934][3.8934:9072](),[3.9072][3.937:982]()
    if let Some(prompt_text) = self.prompt {
    prompt = prompt.with_prompt(prompt_text);
    }
    Ok(Some(prompt.interact()?))
    [3.8934]
    [3.9111]
    Ok(Some(confirm.interact()?))
  • replacement in l10n_embed_interaction/src/lib.rs at line 62
    [3.3949][3.3949:4104]()
    pub fn $prompt_name<'environment>(&'environment self) -> $prompt_type<'environment> {
    $prompt_type::new_from_environment(self)
    [3.3949]
    [3.4104]
    pub fn $prompt_name<'environment, L: Localize>(
    &'environment self,
    prompt: L,
    ) -> $prompt_type<'environment> {
    $prompt_type::new_from_environment(self, prompt)
  • replacement in l10n_embed_interaction/src/lib.rs at line 72
    [3.4138][3.4138:4219]()
    // Create constructors on InteractionEnvironment for different interaction types
    [3.4138]
    [3.4219]
    // Create constructors on InteractionEnvironment for different prompt types
  • edit in l10n_embed_interaction/src/lib.rs at line 74
    [3.4260][3.4260:4299]()
    impl_constructor!(new_editor, Editor);
  • edit in l10n_embed_interaction/src/lib.rs at line 77
    [3.4418]
    [3.4418]
    // Special implementation for text editor as the signature is different
    impl InteractionEnvironment {
    pub fn new_editor<'environment>(&'environment self, extension: &str) -> Editor<'environment> {
    Editor::new_from_environment(self, extension)
    }
    }
  • replacement in l10n_embed_interaction/src/editor.rs at line 5
    [3.4822][3.10500:10531](),[3.10500][3.10500:10531]()
    extension: Option<String>,
    [3.4822]
    [3.374]
    extension: String,
    executable: Option<String>,
  • replacement in l10n_embed_interaction/src/editor.rs at line 10
    [3.4865][3.4865:4965]()
    pub(crate) fn new_from_environment(environment: &'environment InteractionEnvironment) -> Self {
    [3.4865]
    [3.4965]
    pub(crate) fn new_from_environment(
    environment: &'environment InteractionEnvironment,
    extension: &str,
    ) -> Self {
  • replacement in l10n_embed_interaction/src/editor.rs at line 16
    [3.5005][3.5005:5034]()
    extension: None,
    [3.5005]
    [3.5034]
    extension: extension.to_string(),
    executable: None,
  • replacement in l10n_embed_interaction/src/editor.rs at line 22
    [3.1193][3.1193:1256](),[3.578][3.10678:10732](),[3.1256][3.10678:10732](),[3.10678][3.10678:10732]()
    pub fn with_extension(mut self, extension: &str) -> Self {
    self.extension = Some(extension.to_string());
    [3.1143]
    [3.10732]
    pub fn with_executable(mut self, executable: &str) -> Self {
    self.executable = Some(executable.to_string());
  • replacement in l10n_embed_interaction/src/editor.rs at line 32
    [3.11044][3.11044:11152]()
    if let Some(extension) = &self.extension {
    editor.extension(extension);
    [3.11044]
    [3.11152]
    // Dialoguer just appends the extension to the file, so add a `.` to separate it
    editor.extension(&format!(".{}", self.extension));
    if let Some(executable) = &self.executable {
    editor.executable(executable);