aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-03-14 13:51:00 +0100
committerHarald Eilertsen <haraldei@anduin.net>2018-03-14 13:52:11 +0100
commita696c1e949b3c3906737bf74bd552dec2cc35eb7 (patch)
treefbe0ebcf41db41614aba0b500a64c9e5b3b9deb4 /src
parentfcbc8709c44b9e295fc702035861de90ea593ef6 (diff)
downloadcheckpw-a696c1e949b3c3906737bf74bd552dec2cc35eb7.tar.gz
checkpw-a696c1e949b3c3906737bf74bd552dec2cc35eb7.tar.bz2
checkpw-a696c1e949b3c3906737bf74bd552dec2cc35eb7.zip
Separate args from passwords on the command line.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 9450068..9e18a85 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -111,12 +111,11 @@ fn check(pw: Password) -> Result<(), Box<::std::error::Error>> {
}
fn main() {
- let mut passwords = Vec::new();
- for arg in env::args().skip(1) {
- passwords.push(Password::new(&arg));
- };
+ let (_args, passwords) : (Vec<String>, Vec<String>) = env::args()
+ .skip(1)
+ .partition(|arg| arg.starts_with('-'));
for pw in passwords {
- check(pw).unwrap();
+ check(Password::new(&pw)).unwrap();
}
}