//! `intermodal` is primarily used as a command-line binary, but does provide a
//! limited public library interface.
//!
//! Please keep in mind that there are no semantic version guarantees for the
//! library interface. It may break or change at any time.
use crate::common::*;
/// Entry point into the IMDL binary.
///
/// Called by `main` in `main.rs`.
///
/// Constructs an `Env` using `Env::main`, containing the command line
/// arguments, the current working directory, a handle to standard error,
/// standard output, and standard input.
///
/// Calls `Env::status` which runs the program, prints error messages, and
/// returns a status code in case there was an error.
///
/// Errors
/// ------
///
/// In case of an error, a nonzero status code is returned. This status code can
/// be passed to `std::process::exit`, to exit the process and report its
/// failure to the system.
pub fn run(args: impl Iterator<Item = impl Into<OsString>>) -> Result<(), i32> {
let mut env = match Env::main(args) {
Ok(env) => env,
Err(err) => {
eprintln!("{err}");
return Err(EXIT_FAILURE);
}
};
env.status()
}