use myc::ast::environment::Environment; use clap::Parser; use std::fs; use std::path::PathBuf; #[derive(Parser)] #[command(author, version, about = "MYC AST Compiler CLI", long_about = None)] struct Cli { /// The script file to run #[arg(value_name = "FILE")] file: Option, /// Run a script string directly #[arg(short, long)] eval: Option, } fn main() { let cli = Cli::parse(); let env = Environment::new(); if let Some(script_str) = cli.eval { execute(&env, &script_str); } else if let Some(file_path) = cli.file { match fs::read_to_string(&file_path) { Ok(content) => execute(&env, &content), Err(e) => { eprintln!("Error reading file {:?}: {}", file_path, e); std::process::exit(1); } } } else { println!("MYC AST Compiler CLI. Use --help for usage."); } } fn execute(env: &Environment, source: &str) { match env.run_script(source) { Ok(result) => println!("{}", result), Err(e) => { eprintln!("Error: {}", e); std::process::exit(1); } } }