From d4e7d66b911e012f176801656221bc2e576b0d5f Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Wed, 27 Sep 2023 15:03:30 +0200 Subject: [PATCH] CLI: dialoguer bump and breaking changes (#1333) --- Cargo.lock | 5 +++-- cli/Cargo.toml | 4 +++- cli/src/error.rs | 3 +++ cli/src/helper.rs | 13 ++++++------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e477d78b9..d4faf0f7b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -770,12 +770,13 @@ dependencies = [ [[package]] name = "dialoguer" -version = "0.10.4" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59c6f2989294b9a498d3ad5491a79c6deb604617378e1cdc4bfc1c1361fe2f87" +checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" dependencies = [ "console", "shell-words", + "thiserror", "zeroize", ] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index fd783982d0..30c55ba788 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -33,7 +33,9 @@ clap = { version = "4.4.4", default-features = false, features = [ "env", ] } colored = { version = "2.0.4", default-features = false } -dialoguer = { version = "0.10.4", default-features = false, features = ["password"] } +dialoguer = { version = "0.11.0", default-features = false, features = [ + "password", +] } dotenvy = { version = "0.15.7", default-features = false } fern-logger = { version = "0.5.0", default-features = false } humantime = { version = "2.1.0", default-features = false } diff --git a/cli/src/error.rs b/cli/src/error.rs index bea7e656b2..6c6887a293 100644 --- a/cli/src/error.rs +++ b/cli/src/error.rs @@ -1,6 +1,7 @@ // Copyright 2022 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +use dialoguer::Error as DialoguerError; use fern_logger::Error as LoggerError; use iota_sdk::{ client::error::Error as ClientError, types::block::Error as BlockError, wallet::error::Error as WalletError, @@ -14,6 +15,8 @@ pub enum Error { Block(#[from] BlockError), #[error("client error: {0}")] Client(Box), + #[error("dialoguer error: {0}")] + Dialoguer(#[from] DialoguerError), #[error("io error: {0}")] Io(#[from] std::io::Error), #[error("logger error: {0}")] diff --git a/cli/src/helper.rs b/cli/src/helper.rs index 41669185c0..5be5970080 100644 --- a/cli/src/helper.rs +++ b/cli/src/helper.rs @@ -21,13 +21,12 @@ use crate::{error::Error, println_log_error, println_log_info}; const DEFAULT_MNEMONIC_FILE_PATH: &str = "./mnemonic.txt"; pub fn get_password(prompt: &str, confirmation: bool) -> Result { - let mut password = dialoguer::Password::new(); - - password.with_prompt(prompt); + let mut password = dialoguer::Password::new().with_prompt(prompt); if confirmation { - password.with_prompt("Provide a new Stronghold password"); - password.with_confirmation("Confirm password", "Password mismatch"); + password = password + .with_prompt("Provide a new Stronghold password") + .with_confirmation("Confirm password", "Password mismatch"); } Ok(password.interact()?.into()) @@ -103,13 +102,13 @@ pub async fn enter_or_generate_mnemonic() -> Result { .default(0) .interact_on(&Term::stderr())?; - let mnemnonic = match selected_choice { + let mnemonic = match selected_choice { 0 => generate_mnemonic(None, None).await?, 1 => enter_mnemonic()?, _ => unreachable!(), }; - Ok(mnemnonic) + Ok(mnemonic) } pub async fn generate_mnemonic(