/* 1:1 */
use std::process;
/* 2:1 */
use std::env;
/* 4:1 */
pub mod builder;
/* 5:1 */
pub mod codegen;
/* 6:1 */
pub mod transpiler;
/* 8:1 */
fn main() -> ()
{

    /* 9:5 */
    let args: Vec<String> = env::args().collect();
    /* 11:5 */
    if args.len() < 2
    {
        /* 12:9 */
        print_usage();
        /* 13:9 */
        process::exit(1);
    }
    /* 16:5 */
    match args[1].as_str() {
        "run" | "build" | "check" | "r" | "b" | "c" =>
        {
            /* 18:13 */
            let (config, root) = transpiler::build();
            /* 19:13 */
            println!("");
            /* 20:13 */
            if builder::build(args, config, root)
            {
                /* 21:17 */
                println!("\x1b[32m\nBuild successful\x1b[0m");
            }
            else
            {
                /* 23:17 */
                println!("\x1b[31m\nBuild failed\x1b[0m");
            }
        }
        "transpile" | "t" =>
        {
            /* 27:13 */
            transpiler::build();
        }
        "version" | "--version" | "-v" =>
        {
            /* 30:13 */
            println!("mist {}", env!("CARGO_PKG_VERSION"));
        }
        "help" | "--help" | "-h" =>
        {
            /* 33:13 */
            print_usage();
        }
        unknown =>
        {
            /* 36:13 */
            eprintln!("error: unknown command '{}'\n", unknown);
            /* 37:13 */
            print_usage();
            /* 38:13 */
            process::exit(1);
        }
    }
}

/* 43:1 */
fn print_usage() -> ()
{

    /* 44:5 */
    println!("Mist - the mist compiler\n");
    /* 45:5 */
    println!("󰖟 View our documentation! \x1b[35mhttps://mist.selimaj.dev\x1b[0m");
    /* 46:5 */
    println!(" Follow us on github!    \x1b[35mhttps://github.com/mist-go\x1b[0m\n");
    /* 47:5 */
    println!("usage:");
    /* 48:5 */
    println!(" \x1b[36m mist run\x1b[0m,\x1b[36m r\x1b[0m            run the project in the current directory\n");
    /* 49:5 */
    println!(" \x1b[36m mist build\x1b[0m,\x1b[36m b\x1b[0m          build the project in the current directory\n");
    /* 52:5 */
    println!(" \x1b[36m mist transpile\x1b[0m,\x1b[36m t\x1b[0m      transpile the project in the current directory\n");
    /* 55:5 */
    println!(" \x1b[36m mist check\x1b[0m,\x1b[36m c\x1b[0m          check the project in the current directory\n");
    /* 58:5 */
    println!(" \x1b[36m mist version \x1b[0m          print the compiler version\n");
    /* 59:5 */
    println!(" \x1b[36m mist help\x1b[0m              print this message\n");
}

