#[cfg(all(feature = "mimalloc", not(debug_assertions)))]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
fn main() {
let embedder = &aube_util::identity::AUBE;
if is_usage_invocation() {
let mut cmd = aube::command();
clap_usage::generate(&mut cmd, embedder.name, &mut std::io::stdout());
return;
}
std::process::exit(aube::cli_main(embedder));
}
fn is_usage_invocation() -> bool {
let mut args = std::env::args_os();
let invoked_as_aube = args
.next()
.as_deref()
.map(std::path::Path::new)
.and_then(|p| p.file_stem())
.and_then(|s| s.to_str())
.map(|stem| {
!matches!(
stem.to_ascii_lowercase().as_str(),
"aubr" | "aubx" | "node" | "npm" | "npx" | "pnpm" | "pnpx" | "yarn" | "yarnpkg"
)
})
.unwrap_or(true);
invoked_as_aube && args.next().as_deref() == Some(std::ffi::OsStr::new("usage"))
}