replacement in l10n_embed_interaction/src/prompt/select.rs at line 1
− use super::macros::{impl_with_default, impl_with_prompt};
+ use super::macros::impl_with_default;
edit in l10n_embed_interaction/src/prompt/select.rs at line 7
+ localized_prompt: String,
edit in l10n_embed_interaction/src/prompt/select.rs at line 10
− prompt: Option<String>,
edit in l10n_embed_interaction/src/prompt/select.rs at line 13
− impl_with_prompt!(Select);
replacement in l10n_embed_interaction/src/prompt/select.rs at line 15
− pub(crate) fn new_from_environment(environment: &'environment InteractionEnvironment) -> Self {
+ 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
edit in l10n_embed_interaction/src/prompt/select.rs at line 26
replacement in l10n_embed_interaction/src/prompt/select.rs at line 42
− let mut prompt = dialoguer::FuzzySelect::with_theme(&*super::THEME);
+ 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};
+ use super::macros::impl_with_validator;
replacement in l10n_embed_interaction/src/prompt/password.rs at line 6
[3.2243]→[3.2243:2263](∅→∅) + localized_prompt: String,
edit in l10n_embed_interaction/src/prompt/password.rs at line 12
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
− pub(crate) fn new_from_environment(environment: &'environment InteractionEnvironment) -> Self {
+ 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
+ prompt: localized_prompt,
edit in l10n_embed_interaction/src/prompt/password.rs at line 30
[3.1001]→[3.1001:1027](∅→∅) replacement in l10n_embed_interaction/src/prompt/password.rs at line 43
[3.3099]→[3.3099:3138](∅→∅) − prompt: confirmation_text,
+ localized_prompt: confirmation_text,
replacement in l10n_embed_interaction/src/prompt/password.rs at line 53
− let mut prompt = dialoguer::Password::with_theme(&*super::THEME);
+ 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);
+ 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](∅→∅) 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};
+ 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};
+ use super::macros::impl_with_validator;
edit in l10n_embed_interaction/src/prompt/input.rs at line 7
+ 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 {
+ 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
edit in l10n_embed_interaction/src/prompt/input.rs at line 25
[3.2296]→[3.2296:2322](∅→∅) 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);
+ 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};
+ use super::macros::impl_with_default;
edit in l10n_embed_interaction/src/prompt/confirm.rs at line 3
+
+ use l10n_embed::Localize;
edit in l10n_embed_interaction/src/prompt/confirm.rs at line 8
+ 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 {
+ 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
edit in l10n_embed_interaction/src/prompt/confirm.rs at line 25
[3.2927]→[3.2927:2953](∅→∅) 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);
+ 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);
+ 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()?))
+ 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)
+ 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
+ // 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
+
+ // 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>,
+ 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 {
+ 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: 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());
+ 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);
+ // 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);