diff options
author | Teddy Wing | 2018-03-01 22:10:25 +0100 |
---|---|---|
committer | Teddy Wing | 2018-03-01 22:10:25 +0100 |
commit | f43eafeab711ea4be4a71c732228b1244466e9b4 (patch) | |
tree | 55f98b65adbb37d9ae388398970f750934200095 /src | |
parent | 43cf870c98c98d2c818178cc4b9d14810a3cc7a9 (diff) | |
download | Passextract-f43eafeab711ea4be4a71c732228b1244466e9b4.tar.bz2 |
Use `-i` argument to hide passwords
Connect the `-i` argument flag to the renderer. If the arg was passed,
hide passwords, otherwise show them.
Change `args.first()` to `args.get(1)` because the actual first element
is the command executable.
Not happy with the condition I'm using here to grab the password file or
the STDIN `-`. It doesn't read well at all. It all does work, but this
part I want to rewrite to make it easier to read.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index ffe6329..69f7736 100644 --- a/src/main.rs +++ b/src/main.rs @@ -92,14 +92,15 @@ fn is_password_line(line: &str) -> bool { fn main() { let args: Vec<String> = env::args().collect(); - let hide_password = match args.first() { + let hide_password = match args.get(1) { Some(arg) if arg == "-i" => true, Some(_) => false, None => false, }; - let input = if args.len() > 1 { - &args[1] + let input = if hide_password && args.len() > 2 || + !hide_password && args.len() > 1 { + &args[args.len() - 1] } else { "-" }; @@ -127,7 +128,7 @@ fn main() { term.printline_with_cell(selection.x, selection.y, "->", knockout_cell); for (i, s) in options.iter().enumerate() { - if is_password_line(s) { + if hide_password && is_password_line(s) { term.printline(5, i + 2, "p: ") } else { term.printline(5, i + 2, s) |