OXYGENHUB
# ebb9210bad0c oxygen / src / main.rs
835 B · Rust · last changed Memory per phase with a counting allocator 1 month ago source blame history raw
ff0af1ee unknown 1
//! `oxy`: command-line interface for Oxygen.
fce44ae9 Andy McCall ↶ 2
//!
3
//! Command definitions and dispatch live in `cli`; each command group has
4
//! its own module there.
1983686f Andy McCall ↶ 5
fce44ae9 Andy McCall ↶ 6
mod cli;
1983686f Andy McCall ↶ 7
d443639b Andy McCall ↶ 8
#[cfg(feature = "alloc-stats")]
9
#[global_allocator]
10
static ALLOC: oxy_core::alloc_stats::Counting = oxy_core::alloc_stats::Counting;
11
ff0af1ee unknown 12
fn main() {
5b1114a0 Andy McCall ↶ 13
    // Behave like other CLI tools when output is piped into `head`: die
14
    // quietly on SIGPIPE instead of panicking on a failed write.
15
    #[cfg(unix)]
16
    unsafe {
17
        libc::signal(libc::SIGPIPE, libc::SIG_DFL);
18
    }
d443639b Andy McCall ↶ 19
    let result = cli::run();
20
    oxy_core::timing::memory_summary();
21
    match result {
ff0af1ee unknown 22
        Ok(code) => std::process::exit(code),
23
        Err(e) => {
135212de Andy McCall ↶ 24
            cli::ui::init(false);
25
            eprintln!("{} {e:#}", cli::ui::err("error:"));
ff0af1ee unknown 26
            std::process::exit(1);
27
        }
28
    }
29
}