Skip to content

Commit

Permalink
Merge pull request #1338 from messense/dialoguer-password
Browse files Browse the repository at this point in the history
Replace `rpassword` with `dialoguer`
  • Loading branch information
messense authored Dec 6, 2022
2 parents ccb02d1 + 06b522b commit 9d807d6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 32 deletions.
29 changes: 7 additions & 22 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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"]

Expand Down
19 changes: 11 additions & 8 deletions src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9d807d6

Please sign in to comment.