skeleton continues

This commit is contained in:
Qyriad 2026-01-27 17:20:04 +01:00
parent bcd11513ef
commit e5d0bdf0c0
5 changed files with 161 additions and 101 deletions

View file

@ -1,17 +1,20 @@
use std::error::Error as StdError;
use std::io::IsTerminal;
use std::{error::Error as StdError, sync::Arc};
use std::io::{self, IsTerminal};
use std::path::Path;
use std::process::ExitCode;
use append_override::source::SourceFile;
use clap::{ColorChoice, Parser as _};
use fs_err::File;
use fs_err::os::unix::fs::OpenOptionsExt;
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::Auto => io::stdin().is_terminal(),
ColorChoice::Never => false,
});
if cfg!(debug_assertions) {
@ -23,8 +26,18 @@ fn main_wrapped() -> Result<(), Box<dyn StdError + Send + Sync + 'static>> {
// Get what file that thing is defined in.
let def_path = append_override::get_where(&args.name, filepath)?;
let def_path = Arc::from(def_path);
let mut opts = File::options();
opts
.read(true)
.write(true)
.create(false)
.custom_flags(libc::O_CLOEXEC);
let source_file = SourceFile::open_from(Arc::clone(&def_path), opts)?;
append_override::get_highest_prio(&args.name, &def_path)?;
let last_def_line = append_override::get_highest_prio(&args.name, source_file)?;
eprintln!("{last_def_line}");
Ok(())
}