From d33cb027357c7cc82679548ee999ead2cc2a6ecc Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 6 May 2025 14:51:02 +0100 Subject: chore: bump dialoguer v0.11.0 and fix breaking changes --- src/lib/cli_interactor.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/lib') diff --git a/src/lib/cli_interactor.rs b/src/lib/cli_interactor.rs index 1b74101..8fca81d 100644 --- a/src/lib/cli_interactor.rs +++ b/src/lib/cli_interactor.rs @@ -19,20 +19,21 @@ pub trait InteractorPrompt { } impl InteractorPrompt for Interactor { fn input(&self, parms: PromptInputParms) -> Result { - let mut input = Input::with_theme(&self.theme); - input.with_prompt(parms.prompt).allow_empty(parms.optional); + let mut input = Input::with_theme(&self.theme) + .with_prompt(parms.prompt) + .allow_empty(parms.optional) + .report(parms.report); if !parms.default.is_empty() { - input.default(parms.default); + input = input.default(parms.default); } - input.report(parms.report); Ok(input.interact_text()?) } fn password(&self, parms: PromptPasswordParms) -> Result { - let mut p = Password::with_theme(&self.theme); - p.with_prompt(parms.prompt); - p.report(parms.report); + let mut p = Password::with_theme(&self.theme) + .with_prompt(parms.prompt) + .report(parms.report); if parms.confirm { - p.with_confirmation("confirm password", "passwords didnt match..."); + p = p.with_confirmation("confirm password", "passwords didnt match..."); } let pass: String = p.interact()?; Ok(pass) @@ -45,27 +46,25 @@ impl InteractorPrompt for Interactor { Ok(confirm) } fn choice(&self, parms: PromptChoiceParms) -> Result { - let mut choice = dialoguer::Select::with_theme(&self.theme); - choice + let mut choice = dialoguer::Select::with_theme(&self.theme) .with_prompt(parms.prompt) .report(parms.report) .items(&parms.choices); if let Some(default) = parms.default { if std::env::var("NGITTEST").is_err() { - choice.default(default); + choice = choice.default(default); } } choice.interact().context("failed to get choice") } fn multi_choice(&self, parms: PromptMultiChoiceParms) -> Result> { // the colorful theme is not very clear so falling back to default - let mut choice = dialoguer::MultiSelect::default(); - choice + let mut choice = dialoguer::MultiSelect::default() .with_prompt(parms.prompt) .report(parms.report) .items(&parms.choices); if let Some(defaults) = parms.defaults { - choice.defaults(&defaults); + choice = choice.defaults(&defaults); } choice.interact().context("failed to get choice") } -- cgit v1.2.3