Hello, I'm new to rust, so I don't understand some things.
If you have time to explain the fix and help me to do it: thank you!
#[allow(unused_imports)]
use owo_colors::OwoColorize;
mod display;
macro_rules! error {
($($e:tt)*) => {
eprintln!("{}: {}", "error".bold().red(), format!($($e)*));
};
}
macro_rules! warn {
($($e:tt)*) => {
eprintln!("{}: {}", "warning".bold().yellow(), format!($($e)*));
};
}
macro_rules! exit {
// rule one: does not specify the exit code
() => {
std::process::exit(0);
};
// rule two: specify the exit code
($ec:literal) => {
if $ec == 1 {
println!("{}: exiting with exit code 1", "warning".bold().yellow());
}
std::process::exit($ec);
};
}
fn main() {
let mut shell_arguments = pico_args::Arguments::from_env();
let version = shell_arguments.contains(["-v", "--v"]);
let help = shell_arguments.contains(["-h", "--help"]);
if help {
display::help::display();
exit!();
}
if version {
display::version::display();
exit!();
}
let input = shell_arguments
.value_from_str(["-i", "--input"])
.unwrap_or_else(|e| {
error!("missing input argument!");
exit!(1);
});
todo!();
}