From 06b522beb9355d957bfa28f34405bec70df2be7a Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 6 Dec 2022 13:20:09 +0800 Subject: [PATCH] Replace `rpassword` with `dialoguer` --- Cargo.lock | 29 +++++++---------------------- Cargo.toml | 3 +-- src/upload.rs | 19 +++++++++++-------- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 190a7328c..6885c91cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -763,6 +763,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a92e7e37ecef6857fdc0c0c5d42fd5b0938e46590c2183cc92dd310a6d078eb1" dependencies = [ "console", + "zeroize", ] [[package]] @@ -1498,7 +1499,6 @@ dependencies = [ "pyproject-toml", "python-pkginfo", "regex", - "rpassword", "rustc_version", "rustversion", "semver", @@ -2240,27 +2240,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rpassword" -version = "7.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" -dependencies = [ - "libc", - "rtoolbox", - "winapi", -] - -[[package]] -name = "rtoolbox" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "rustc_version" version = "0.4.0" @@ -3407,6 +3386,12 @@ dependencies = [ "syn", ] +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" + [[package]] name = "zip" version = "0.6.3" diff --git a/Cargo.toml b/Cargo.toml index cd0d53250..49b7c6425 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,7 +79,6 @@ minijinja = { version = "0.26.0", optional = true } bytesize = { version = "1.0.1", optional = true } configparser = { version = "3.0.0", optional = true } multipart = { version = "0.18.0", features = ["client"], default-features = false, optional = true } -rpassword = { version = "7.0.0", optional = true } ureq = { version = "2.3.1", features = ["gzip", "socks-proxy"], default-features = false, optional = true } native-tls-crate = { package = "native-tls", version = "0.2.8", optional = true } keyring = { version = "1.1.1", optional = true } @@ -97,7 +96,7 @@ full = ["cross-compile", "log", "scaffolding", "upload"] log = ["tracing-subscriber"] -upload = ["ureq", "multipart", "rpassword", "configparser", "bytesize"] +upload = ["ureq", "multipart", "configparser", "bytesize", "dialoguer/password"] # keyring doesn't support *BSD so it's not enabled in `full` by default password-storage = ["upload", "keyring"] diff --git a/src/upload.rs b/src/upload.rs index c2db19a9d..1466f33c1 100644 --- a/src/upload.rs +++ b/src/upload.rs @@ -141,14 +141,17 @@ fn get_password(_username: &str) -> String { }; } - rpassword::prompt_password("Please enter your password: ").unwrap_or_else(|_| { - // So we need this fallback for pycharm on windows - let mut password = String::new(); - io::stdin() - .read_line(&mut password) - .expect("Failed to read line"); - password.trim().to_string() - }) + dialoguer::Password::new() + .with_prompt("Please enter your password") + .interact() + .unwrap_or_else(|_| { + // So we need this fallback for pycharm on windows + let mut password = String::new(); + io::stdin() + .read_line(&mut password) + .expect("Failed to read line"); + password.trim().to_string() + }) } fn get_username() -> String {