2026-01-27 17:20:04 +01:00
|
|
|
use std::io::{self, IsTerminal};
|
2026-01-27 11:29:10 +01:00
|
|
|
use std::process::ExitCode;
|
2026-01-28 19:30:59 +01:00
|
|
|
use std::{error::Error as StdError, sync::Arc};
|
2026-01-27 11:29:10 +01:00
|
|
|
|
|
|
|
|
use clap::{ColorChoice, Parser as _};
|
|
|
|
|
|
|
|
|
|
fn main_wrapped() -> Result<(), Box<dyn StdError + Send + Sync + 'static>> {
|
2026-02-02 13:42:07 +01:00
|
|
|
let args = Arc::new(dynix::Args::parse());
|
2026-01-27 11:29:10 +01:00
|
|
|
|
2026-01-30 19:39:58 +01:00
|
|
|
dbg!(&args);
|
|
|
|
|
|
2026-02-02 11:34:52 +01:00
|
|
|
let success = dynix::CLI_ENABLE_COLOR.set(match args.color {
|
2026-01-27 11:29:10 +01:00
|
|
|
ColorChoice::Always => true,
|
2026-01-27 17:20:04 +01:00
|
|
|
ColorChoice::Auto => io::stdin().is_terminal(),
|
2026-01-27 11:29:10 +01:00
|
|
|
ColorChoice::Never => false,
|
|
|
|
|
});
|
|
|
|
|
if cfg!(debug_assertions) {
|
|
|
|
|
success.expect("logic error in CLI_ENABLE_COLOR");
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 13:42:07 +01:00
|
|
|
use dynix::args::Subcommand::*;
|
|
|
|
|
match &args.subcommand {
|
|
|
|
|
Append(append_args) => dynix::do_append(args.clone(), append_args.clone())?,
|
2026-01-29 13:52:54 +01:00
|
|
|
};
|
2026-01-27 11:29:10 +01:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() -> ExitCode {
|
|
|
|
|
match main_wrapped() {
|
|
|
|
|
Ok(_) => ExitCode::SUCCESS,
|
|
|
|
|
Err(e) => {
|
2026-02-02 11:34:52 +01:00
|
|
|
eprintln!("dynix: error: {}", e);
|
2026-01-27 11:29:10 +01:00
|
|
|
ExitCode::FAILURE
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|