From e21b2fddd58cacb4dbd99699c2bd83cb5bf2a349 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 14 Mar 2018 16:08:33 +0100 Subject: Print usage if no args or passwords given. --- src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 9e18a85..b742d95 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,11 +110,20 @@ fn check(pw: Password) -> Result<(), Box<::std::error::Error>> { Ok(()) } +fn print_usage() { + println!("Usage: checkpw ..."); +} + fn main() { - let (_args, passwords) : (Vec, Vec) = env::args() + let (args, passwords) : (Vec, Vec) = env::args() .skip(1) .partition(|arg| arg.starts_with('-')); + if args.is_empty() && passwords.is_empty() { + print_usage(); + return; + } + for pw in passwords { check(Password::new(&pw)).unwrap(); } -- cgit v1.2.3