1
use clap::Parser;
2
use color_eyre::eyre::Context;
3
use color_eyre::Result;
4
use env_logger::Target;
5
use zork::{cli::input::CliArgs, utils::logger::config_logger, worker::run_zork};
6

            
7
/// The entry point for the binary generated
8
/// for the program
9
fn main() -> Result<()> {
10
    color_eyre::install()?;
11
    let process_start_time = std::time::Instant::now();
12

            
13
    let cli_args = CliArgs::parse();
14
    config_logger(cli_args.verbose, Target::Stdout)
15
        .with_context(|| "Error configuring the logger")?;
16

            
17
    log::info!("Launching a new Zork++ program");
18
    match run_zork(&cli_args) {
19
        Ok(_) => {
20
            log::info!(
21
                "[SUCCESS] - The process ended successfully, taking a total time in complete of: {:?} ms",
22
                process_start_time.elapsed().as_millis()
23
            );
24
            Ok(())
25
        }
26
        Err(err) => {
27
            log::error!(
28
                "[FAILED] - The process failed, taking a total time in complete of: {:?} ms",
29
                process_start_time.elapsed().as_millis()
30
            );
31
            Err(err)
32
        }
33
    }?;
34

            
35
    Ok(())
36
}