Skip to content

Commit

Permalink
CLI: dialoguer bump and breaking changes (#1333)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Sep 27, 2023
1 parent bd96aee commit d4e7d66
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
3 changes: 3 additions & 0 deletions cli/src/error.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -14,6 +15,8 @@ pub enum Error {
Block(#[from] BlockError),
#[error("client error: {0}")]
Client(Box<ClientError>),
#[error("dialoguer error: {0}")]
Dialoguer(#[from] DialoguerError),
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("logger error: {0}")]
Expand Down
13 changes: 6 additions & 7 deletions cli/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Password, Error> {
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())
Expand Down Expand Up @@ -103,13 +102,13 @@ pub async fn enter_or_generate_mnemonic() -> Result<Mnemonic, Error> {
.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(
Expand Down

0 comments on commit d4e7d66

Please sign in to comment.