2025-02-06 17:55:54 +00:00
|
|
|
use std::process::exit;
|
|
|
|
|
2025-02-06 10:34:46 +00:00
|
|
|
use clap::Parser;
|
|
|
|
use rox::cli::{Cli, Commands};
|
2025-02-06 17:55:54 +00:00
|
|
|
use tracing::error;
|
2025-02-06 10:34:46 +00:00
|
|
|
|
2025-02-07 08:21:23 +00:00
|
|
|
/// Cli entrypoint.
|
2025-02-06 10:34:46 +00:00
|
|
|
fn main() {
|
|
|
|
if std::env::var_os("RUST_LOG").is_none() {
|
|
|
|
std::env::set_var("RUST_LOG", "info");
|
|
|
|
}
|
|
|
|
tracing_subscriber::fmt::init();
|
|
|
|
|
|
|
|
let cli = Cli::parse();
|
|
|
|
|
|
|
|
match &cli.command {
|
|
|
|
Commands::Compile(compile_config) => {
|
2025-02-06 17:55:54 +00:00
|
|
|
if !&compile_config.source.exists() {
|
|
|
|
error!(
|
|
|
|
"{} does not exist",
|
|
|
|
&compile_config.source.to_string_lossy()
|
|
|
|
);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Err(e) = rox::compile(&compile_config.source) {
|
|
|
|
error!(
|
|
|
|
"failed to compile {}: {}",
|
|
|
|
&compile_config.source.to_string_lossy(),
|
|
|
|
e
|
|
|
|
);
|
|
|
|
}
|
2025-02-06 10:34:46 +00:00
|
|
|
}
|
|
|
|
Commands::Repl => {
|
|
|
|
rox::repl();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|