diff options
| -rw-r--r-- | src/main.rs | 16 | 
1 files changed, 15 insertions, 1 deletions
| diff --git a/src/main.rs b/src/main.rs index 7411c1a..28b0259 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,6 +89,20 @@ fn is_password_line(line: &str) -> bool {      line.starts_with("p: ")  } +/// Replaces the password on a password line with "*"s. +/// +/// # Examples +/// +/// ``` +/// assert_eq!(hide_password_line("p: secret"), "p: ******); +/// ``` +fn hide_password_line(line: &str) -> String { +    const KEY_LENGTH: usize = 3; +    let password_length = line.len() - KEY_LENGTH; + +    format!("p: {}", "*".repeat(password_length)) +} +  fn main() {      let args: Vec<String> = env::args().collect(); @@ -132,7 +146,7 @@ fn main() {          for (i, s) in options.iter().enumerate() {              if hide_password && is_password_line(s) { -                term.printline(5, i + 2, "p: ") +                term.printline(5, i + 2, &hide_password_line(s))              } else {                  term.printline(5, i + 2, s)              } | 
