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 == 0 or == 1 Behaviour for version not being == 0 or == 1 is undefined When it is executed it returns a number that is determined by comparing arg to command nicknames (capital insensitive) and if arg is in command nicknames it returns Some(i) where i == the index that it is at Else if all_is_255 && arg == “all” than Some(255) is returned Else if arg is a decimal integer it returns arg as a integer Else it returns None if version == 0 or Some(245) if version == 1
§Examples
asserteq!(Some(0),command_ifyer::what_to_execute(0,"fOO",&["Foo","Bar"],true));
asserteq!(Some(1),command_ifyer::what_to_execute(0,"1",&["hi","HeLlo"],false));
asserteq!(Some(255),command_ifyer::what_to_execute(0, "all", &["hi","HeLlo"]),true);
asserteq!(Some(3),command_ifyer::what_to_execute(0, "all", &["hi","HeLlo","All"], true))
asserteq!(None,command_ifyer::what_to_execute(0,"When is the Testificate Man full lenght movie going to come out?",&["Hi","HeLlo"],false))
let args: Vec<String> = std::env::args().collect();
let mut thing_to_execute = Some(255);
if args.len() > 1 {
thing_to_execute = command_ifyer::what_to_execute(0, &args[1], &["Foo", "Bar"], true);
}
if thing_to_execute == Some(0)|| thing_to_execute == Some(255) {
println("foo");
}
if thing_to_execute == Some(255) || thing_to_execute == Some(1) {
println!("bar");
}