🚀 meta: initial commit

This commit is contained in:
2023-11-18 13:18:05 -05:00
commit 271f42c124
4 changed files with 61 additions and 0 deletions

35
src/main.rs Normal file
View File

@@ -0,0 +1,35 @@
use std::process::{exit, Command};
fn main() -> Result<(), std::io::Error> {
dotenvy::dotenv().unwrap();
let mut args = std::env::args_os();
let _dotenv = args.next();
let first = args.next().ok_or(std::io::Error::other(
"pass a command and args after dotenv when running the program",
))?;
let mut command = Command::new(first);
for arg in args {
command.arg(arg);
}
let mut child = command.spawn()?;
let exit_status = child.wait()?;
match exit_status.code() {
Some(code) => exit(code),
None => {
if exit_status.success() {
Ok(())
} else {
Err(std::io::Error::other(
"program exited unsuccessfully without a code",
))
}
}
}
}