1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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() -> Result<(), i32> {
  let mut env = match Env::main() {
    Ok(env) => env,
    Err(err) => {
      eprintln!("{}", err);
      return Err(EXIT_FAILURE);
    }
  };

  env.status()
}