From 28030fd0830478872be2b9e86b74e0c054a96111 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sat, 24 May 2025 17:31:33 +0200 Subject: implemented a workflow, but citekey matching still buggy --- src/cliargs.rs | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'src/cliargs.rs') diff --git a/src/cliargs.rs b/src/cliargs.rs index 6fd30e1..a9b12fd 100644 --- a/src/cliargs.rs +++ b/src/cliargs.rs @@ -33,7 +33,7 @@ pub struct CLIArgs { pub pos_args: Vec, pub cfg_path: Option, pub light_theme: bool, - pub pdf_files: Option>, + pub pdf_path: Option, } impl CLIArgs { @@ -57,8 +57,7 @@ impl CLIArgs { Short('c') | Long("config-file") => args.cfg_path = Some(parser.value()?.parse()?), Long("light-terminal") => args.light_theme = true, Long("merge-pdf-paths") => { - let pdf_dir: PathBuf = parser.value()?.parse()?; - args.pdf_files = collect_pdf_files(pdf_dir); + args.pdf_path = Some(parser.value()?.parse()?); } // Value(pos_arg) => parse_files(&mut args, pos_arg), Value(pos_arg) => args.pos_args.push(pos_arg.into()), @@ -70,37 +69,6 @@ impl CLIArgs { } } -/// This function walks the given dir and collects all pdf files into a `Vec` -pub fn collect_pdf_files(pdf_dir: PathBuf) -> Option> { - let mut files: Vec = Vec::new(); - - // Expand tilde to /home/user - let pdf_dir = if pdf_dir.starts_with("~") { - app::expand_home(&pdf_dir) - } else { - pdf_dir - }; - - // Walk the passed dir and collect all pdf files into vec - if pdf_dir.is_dir() { - for file in WalkDir::new(pdf_dir) { - let f = file.unwrap().into_path(); - if f.is_file() - && f.extension().is_some() - && f.extension().unwrap_or_default().to_ascii_lowercase() == "pdf" - { - files.push(f); - } - } - } - - if files.is_empty() { - None - } else { - Some(files) - } -} - /// This function maps a vector containing paths to another vector containing paths. /// But it will walk all entries of the first vec which are directories /// and put only valid file paths with `.bib` ending to the resulting vec. -- cgit v1.2.3