diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-05-13 14:41:11 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-05-13 14:41:11 +0200 |
commit | 580c9e5286bddd5cea02721e72438a786edbb1b5 (patch) | |
tree | b22de4509e79f514fab26398a8318dbde015537f /bin | |
parent | 27124c2a832d1c9ecbc1f8ebef8108ee6e2621f7 (diff) |
Add command finder helper function
Diffstat (limited to 'bin')
-rw-r--r-- | bin/src/main.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/src/main.rs b/bin/src/main.rs index 7e23d5b7..925fb49f 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -94,11 +94,15 @@ fn get_commands() -> Vec<String> { execs } +fn find_command() -> Option<String> { + env::args().skip(1).filter(|x| !x.starts_with("-")).next() +} + fn main() { let commands = get_commands(); let mut args = env::args(); let _ = args.next(); - let first_arg = match args.next() { + let first_arg = match find_command() { Some(s) => s, None => { help(commands); |