From 3e7d921413320062143065330003926a31bb4437 Mon Sep 17 00:00:00 2001 From: geemili Date: Tue, 19 Jul 2016 13:38:52 -0500 Subject: [PATCH] Fixed bug where flags would not be read --- bin/src/main.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/src/main.rs b/bin/src/main.rs index 32723dc3..8c95adcf 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -99,6 +99,10 @@ fn find_command() -> Option { env::args().skip(1).filter(|x| !x.starts_with("-")).next() } +fn find_flag() -> Option { + env::args().skip(1).filter(|x| x.starts_with("-")).next() +} + fn find_args(command: &str) -> Vec { env::args() .skip(1) @@ -113,9 +117,12 @@ fn main() { let _ = args.next(); let first_arg = match find_command() { Some(s) => s, - None => { - help(commands); - exit(0); + None => match find_flag() { + Some(s) => s, + None => { + help(commands); + exit(0); + }, }, };