diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2018-03-14 16:08:33 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2018-03-14 16:08:33 +0100 |
commit | e21b2fddd58cacb4dbd99699c2bd83cb5bf2a349 (patch) | |
tree | 7724895ebb13e781eb40250d0e98b4a3af147067 /src | |
parent | a696c1e949b3c3906737bf74bd552dec2cc35eb7 (diff) | |
download | checkpw-e21b2fddd58cacb4dbd99699c2bd83cb5bf2a349.tar.gz checkpw-e21b2fddd58cacb4dbd99699c2bd83cb5bf2a349.tar.bz2 checkpw-e21b2fddd58cacb4dbd99699c2bd83cb5bf2a349.zip |
Print usage if no args or passwords given.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 10 insertions, 1 deletions
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 <pw>..."); +} + fn main() { - let (_args, passwords) : (Vec<String>, Vec<String>) = env::args() + let (args, passwords) : (Vec<String>, Vec<String>) = 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(); } |