use anyhow::Result;
use std::path::Path;
use std::process::Command;
pub fn build_file(path: &Path, output_dir: &Path) -> Result<()> {
if !path.exists() {
error!("File not found at: {}", path.display());
}
std::fs::create_dir_all(output_dir)?;
let status = match Command::new("javac")
.arg("-d")
.arg(output_dir)
.arg("-encoding")
.arg("UTF-8")
.arg(path)
.status()
{
Ok(status) => status,
Err(_) => error!("javac not found."),
};
if !status.success() {
error!("Compilation failed");
}
success!("File built successfully");
Ok(())
}