aboutsummaryrefslogtreecommitdiff
path: root/src/cliargs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cliargs.rs')
-rw-r--r--src/cliargs.rs36
1 files changed, 2 insertions, 34 deletions
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<PathBuf>,
pub cfg_path: Option<PathBuf>,
pub light_theme: bool,
- pub pdf_files: Option<Vec<PathBuf>>,
+ pub pdf_path: Option<PathBuf>,
}
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<Vec<PathBuf>> {
- let mut files: Vec<PathBuf> = 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.