#[cfg(not(target_family = "wasm"))]
use rudof_cli::{
cli::parser::{Cli, Command},
commands::{CommandContext, CommandFactory},
};
#[cfg(not(target_family = "wasm"))]
use std::env;
#[cfg(target_family = "wasm")]
fn main() {}
#[cfg(not(target_family = "wasm"))]
fn main() -> std::process::ExitCode {
setup();
match run() {
Ok(()) => std::process::ExitCode::SUCCESS,
Err(err) => {
eprintln!(
"{} {}",
rudof_cli::output::error_prefix(),
rudof_cli::output::format_error(&err)
);
std::process::ExitCode::FAILURE
},
}
}
#[cfg(not(target_family = "wasm"))]
fn run() -> anyhow::Result<()> {
use clap::Parser;
let args = clientele::args_os()?;
let cli = Cli::parse_from(args);
match &cli.command {
Some(cmd) => execute(cmd, cli.debug)?,
None => anyhow::bail!("Command not specified. Use --help for available commands."),
}
Ok(())
}
#[cfg(not(target_family = "wasm"))]
fn setup() {
clientele::dotenv().ok();
unsafe {
env::set_var("RUSTEMO_NOTRACE", "1");
}
rudof_cli::logging::init();
}
#[cfg(not(target_family = "wasm"))]
fn execute(cli_command: &Command, debug: u8) -> anyhow::Result<()> {
let command = CommandFactory::create(cli_command.clone())?;
let mut ctx = CommandContext::from_cli(cli_command, debug)?;
command.execute(&mut ctx)?;
Ok(())
}