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
}
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);