skeleton
This commit is contained in:
parent
d8ac4e157d
commit
bcd11513ef
12 changed files with 1042 additions and 5 deletions
40
src/main.rs
Normal file
40
src/main.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue