mod commands;
mod config;
pub(crate) mod dirs;
mod install_scope;
pub mod scaffold;
mod templates;
mod util;
#[cfg(target_os = "windows")]
mod packaging_windows;
#[cfg(target_os = "windows")]
mod windows_manifest;
#[cfg(target_os = "windows")]
#[cfg(any(target_os = "macos", target_os = "windows"))]
pub(crate) use commands::install::aax::build_aax_template;
#[cfg(target_os = "windows")]
#[cfg(any(target_os = "macos", target_os = "windows"))]
pub(crate) use commands::package::PkgFormat;
pub(crate) use config::*;
pub(crate) use util::*;
use std::process::ExitCode;
pub(crate) type Res = std::result::Result<(), Box<dyn std::error::Error>>;
pub(crate) type BoxErr = Box<dyn std::error::Error>;
pub fn run(args: &[String]) -> ExitCode {
let mut filtered: Vec<String> = Vec::with_capacity(args.len());
for a in args {
if a == "-v" || a == "--verbose" {
util::set_verbose(true);
} else {
filtered.push(a.clone());
}
}
let args = &filtered[..];
let cmd = args.first().map(|s| s.as_str()).unwrap_or("");
let result = match cmd {
"install" => commands::install::cmd_install(&args[1..]),
"build" => commands::build::cmd_build(&args[1..]),
"package" => commands::package::cmd_package(&args[1..]),
"remove" => commands::remove::cmd_remove(&args[1..]),
"run" => commands::run::cmd_run(&args[1..]),
"screenshot" => commands::screenshot::cmd_screenshot(&args[1..]),
"test" => commands::test::cmd_test(),
"status" => commands::status::cmd_status(),
"clean" => commands::clean::cmd_clean(&args[1..]),
"reset-au" => commands::reset_au::cmd_reset_au(&args[1..]),
"reset-aax" => commands::reset_aax::cmd_reset_aax(&args[1..]),
"validate" => commands::validate::cmd_validate(&args[1..]),
"doctor" => commands::doctor::cmd_doctor(),
"log-stream-au" => commands::log_stream_au::cmd_log_stream_au(),
other => Err(format!("unknown command: {other:?}").into()),
};
match result {
Ok(()) => ExitCode::SUCCESS,
Err(e) => {
eprintln!("Error: {e}");
ExitCode::FAILURE
}
}
}