From 580c9e5286bddd5cea02721e72438a786edbb1b5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 13 May 2016 14:41:11 +0200 Subject: [PATCH] Add command finder helper function --- bin/src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 { execs } +fn find_command() -> Option { + 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);