Add command finder helper function

This commit is contained in:
Matthias Beyer 2016-05-13 14:41:11 +02:00
parent 27124c2a83
commit 580c9e5286

View file

@ -94,11 +94,15 @@ fn get_commands() -> Vec<String> {
execs execs
} }
fn find_command() -> Option<String> {
env::args().skip(1).filter(|x| !x.starts_with("-")).next()
}
fn main() { fn main() {
let commands = get_commands(); let commands = get_commands();
let mut args = env::args(); let mut args = env::args();
let _ = args.next(); let _ = args.next();
let first_arg = match args.next() { let first_arg = match find_command() {
Some(s) => s, Some(s) => s,
None => { None => {
help(commands); help(commands);