aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs11
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();
}