diff options
| -rw-r--r-- | src/bibiman.rs | 11 | ||||
| -rw-r--r-- | src/cliargs.rs | 6 | ||||
| -rw-r--r-- | src/tui/ui.rs | 2 |
3 files changed, 11 insertions, 8 deletions
diff --git a/src/bibiman.rs b/src/bibiman.rs index 3da0a24..88019d6 100644 --- a/src/bibiman.rs +++ b/src/bibiman.rs @@ -76,8 +76,8 @@ pub struct Bibiman { impl Bibiman { // Constructs a new instance of [`App`]. pub fn new(args: &CLIArgs) -> Result<Self> { - // let main_bibfiles = args.pos_args.clone(); - let main_biblio = BibiSetup::new(&args.pos_args); + // let main_bibfiles = args.fileargs.clone(); + let main_biblio = BibiSetup::new(&args.fileargs); let tag_list = TagList::new(main_biblio.keyword_list.clone()); let search_struct = BibiSearch::default(); let entry_table = EntryTable::new(&main_biblio.entry_list); @@ -122,7 +122,7 @@ impl Bibiman { } pub fn update_lists(&mut self, args: &CLIArgs) { - self.main_biblio = BibiSetup::new(&args.pos_args); + self.main_biblio = BibiSetup::new(&args.fileargs); self.tag_list = TagList::new(self.main_biblio.keyword_list.clone()); self.entry_table = EntryTable::new(&self.main_biblio.entry_list); } @@ -307,7 +307,10 @@ impl Bibiman { let saved_key = citekey.to_owned(); // TODO: Only for testing purposes, needs better logic to find correct file // when using multi file approach - let filepath = args.pos_args[0].clone().into_os_string(); + let filepath = args.fileargs[0].as_os_str(); + let filepath = if args.fileargs.len() == 1 { + args.fileargs.first().unwrap().as_os_str() + }; let filecontent: &str = &self.main_biblio.bibfilestring; let mut line_count = 0; diff --git a/src/cliargs.rs b/src/cliargs.rs index 0a1c0b5..02fc8df 100644 --- a/src/cliargs.rs +++ b/src/cliargs.rs @@ -28,7 +28,7 @@ use walkdir::WalkDir; pub struct CLIArgs { pub helparg: bool, pub versionarg: bool, - pub pos_args: Vec<PathBuf>, + pub fileargs: Vec<PathBuf>, } impl CLIArgs { @@ -53,13 +53,13 @@ pub fn parse_files(args: &mut CLIArgs, pos_arg: OsString) { let path = PathBuf::from(pos_arg); // If pos arg is file, just push it to path vec if path.is_file() { - args.pos_args.push(path); + args.fileargs.push(path); // If pos arg is dir, walk dir and collect bibfiles } else if path.is_dir() { for file in WalkDir::new(path) { let f = file.unwrap().into_path(); if f.is_file() && f.extension().unwrap() == "bib" { - args.pos_args.push(f) + args.fileargs.push(f) } } } else { diff --git a/src/tui/ui.rs b/src/tui/ui.rs index 41a18d8..84a1c29 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -351,7 +351,7 @@ pub fn render_file_info(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: Span::raw("File: ").bold(), Span::raw( // TODO: Only for testing! Need to replace with dir or files vec - args.pos_args[0].file_name().unwrap().to_string_lossy(), + args.fileargs[0].file_name().unwrap().to_string_lossy(), ) .bold(), ]) |
