dynix/src/main.rs

41 lines
1.1 KiB
Rust
Raw Normal View History

2026-01-27 03:29:10 -07:00
use std::error::Error as StdError;
use std::io::IsTerminal;
use std::path::Path;
use std::process::ExitCode;
use clap::{ColorChoice, Parser as _};
fn main_wrapped() -> Result<(), Box<dyn StdError + Send + Sync + 'static>> {
let args = append_override::Parser::parse();
let success = append_override::CLI_ENABLE_COLOR.set(match args.color {
ColorChoice::Always => true,
ColorChoice::Auto => std::io::stdin().is_terminal(),
ColorChoice::Never => false,
});
if cfg!(debug_assertions) {
success.expect("logic error in CLI_ENABLE_COLOR");
}
// FIXME: handle relative paths without leading ./
let filepath = Path::new(&args.file);
// Get what file that thing is defined in.
let def_path = append_override::get_where(&args.name, filepath)?;
append_override::get_highest_prio(&args.name, &def_path)?;
Ok(())
}
fn main() -> ExitCode {
match main_wrapped() {
Ok(_) => ExitCode::SUCCESS,
Err(e) => {
eprintln!("append-override: error: {}", e);
ExitCode::FAILURE
}
}
}