template_rust_project/
cli.rs1use std::ffi::OsString;
2use tracing::error;
3
4pub fn run(args: impl IntoIterator<Item = OsString>) -> Result<(), i32> {
5 let _args: Vec<OsString> = args.into_iter().collect();
6 if _args.len() < 2 {
9 error!("Expecting at least 2 arguments");
10 return Err(1);
11 }
12 Ok(())
13}
14
15#[cfg(test)]
17mod tests {
18 use super::*;
19 use std::ffi::OsString;
20
21 #[test]
22 fn test_run_with_valid_args() {
23 let args = vec![OsString::from("arg1"), OsString::from("arg2")];
24 let result = run(args);
25 assert!(result.is_ok());
26 }
27
28 #[test]
29 fn test_run_with_invalid_args() {
30 let args = vec![OsString::from("invalid_arg")];
31 let result = run(args);
32 assert!(result.is_err());
33 }
34}