pub fn what_to_execute(
version: u128,
arg: &String,
command_nicknames: &[&str],
all_is_255: bool,
) -> Option<usize>
Expand description
Decides what to execute Version must be 0 Arg is the thing that is a number or is in command_nicknames (case insensitive), command_nicknames is a array of alternative names for commands all_is_255 controlls wheater the arg “all”(case insensitive) should output 255
§Examples
use command-ifyer::what_to_execute;
asserteq!(0,command-ifyer(0,"fOO",&["Foo","Bar"],true).unwrap);
asserteq!(1,command-ifyer(0,"1",&["hi","HeLlo"],false).unwrap);
asserteq!(255,command-ifyer(0, "all", &[hi,HeLlo]),true.unwrap);
use command-ifyer::what_to_execute;
use std::env;
let args: Vec<String> = env::args().collect();
let mut thing_to_execute = 255;
if args.len() > 1 {
thing_to_execute = what_to_execute(0,args[1],&["Foo", "Bar"],true).unwrap();
}
if thing_to_execute == 0 || thing_to_execute == 255 {
println("foo");
}
if thing_to_execute == 255 || thing_to_execute == 1 {
println!("bar");
}