Add command finder helper function
This commit is contained in:
parent
27124c2a83
commit
580c9e5286
1 changed files with 5 additions and 1 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue