From 05c226955e58433b2e27ebedd8b12bef9e4101ad Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 4 Apr 2018 17:10:00 +0200 Subject: Return number of pwned passwords as exit code. --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 48b8e4c..7fe7e93 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ extern crate reqwest; extern crate ring; -use std::{env, thread, time}; +use std::{env, thread, time, process}; use std::error::Error; use ring::digest; @@ -132,6 +132,7 @@ fn main() { } let mut first_round = true; + let mut pwn_count = 0; for pw in passwords { if first_round { @@ -146,6 +147,7 @@ fn main() { Ok(num) => { if num > 0 { println!("Password is PWNED! It was found in {} breaches.", num); + pwn_count += 1; } else { println!("Password was not found in any breaches"); @@ -153,4 +155,6 @@ fn main() { } } } + + process::exit(pwn_count); } -- cgit v1.2.3