Skip to main content

kpsewhich/
kpsewhich.rs

1//! A minimal `kpsewhich` clone for debugging: `kpsewhich FORMAT NAME`.
2use retex_kpath::{FileFormat, Kpathsea, Options};
3
4fn main() {
5    let args: Vec<String> = std::env::args().collect();
6    let fmt = match args.get(1).map(String::as_str) {
7        Some("lua") => FileFormat::Lua,
8        Some("fmt") => FileFormat::Fmt,
9        Some("otf") => FileFormat::OpenType,
10        Some("tfm") => FileFormat::Tfm,
11        _ => FileFormat::Tex,
12    };
13    let mut k = Kpathsea::new(Options::lualatex()).unwrap();
14    let t = std::time::Instant::now();
15    let found = k.find_file(&args[2], fmt);
16    eprintln!("path: {:?}", k.search_path(fmt));
17    println!("{found:?} ({:?})", t.elapsed());
18}