From 201aecebcd7c85127df9c43da01fdafc3465e53e Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 2 Jun 2025 17:40:50 +0200 Subject: impl check for valid filepath, update README --- README.md | 13 +++++++++---- src/app.rs | 4 ++-- src/bibiman.rs | 16 ++++++++++++++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a9de6f3..4c176af 100644 --- a/README.md +++ b/README.md @@ -104,10 +104,15 @@ Or through `home-manager` config file: ### Void Linux -I maintain a [PR](https://github.com/void-linux/void-packages/pull/53803) in the -official Void package repos and hope it gets merged soon. Until that happens, -you can easily pull that PR into your local clone of Void packages and build it -with `xbps-src`. +You can install `bibiman` through `xbps`-package manager: + +```bash +# Through xbps directly +sudo xpbs-install bibiman + +# Or using xi from xtools package +xi bibiman +``` ## Usage diff --git a/src/app.rs b/src/app.rs index 15cdfe3..f7e7891 100644 --- a/src/app.rs +++ b/src/app.rs @@ -406,9 +406,9 @@ pub fn open_connected_file(cfg: &BibiConfig, file: &OsStr) -> Result<()> { // } else { // PathBuf::from(file) // }; - let file = PathBuf::from(file); + // let file = PathBuf::from(file); - let file = expand_home(&file).into_os_string(); + // let file = expand_home(&file).into_os_string(); // Pass filepath as argument, pipe stdout and stderr to /dev/null // to keep the TUI clean (where is it piped on Windows???) diff --git a/src/bibiman.rs b/src/bibiman.rs index 583d849..ea9dbf5 100644 --- a/src/bibiman.rs +++ b/src/bibiman.rs @@ -15,6 +15,7 @@ // along with this program. If not, see . ///// +use crate::app::expand_home; use crate::bibiman::entries::EntryTableColumn; use crate::bibiman::{bibisetup::*, search::BibiSearch}; use crate::cliargs::CLIArgs; @@ -674,16 +675,27 @@ impl Bibiman { let object = self.entry_table.entry_table_items[entry_idx].doi_url(); let url = app::prepare_weblink(object); app::open_connected_link(cfg, &url)?; + self.close_popup(); } else if self.popup_area.popup_list[popup_idx].0.contains("File") { // TODO: Selection for multiple files // let object = self.entry_table.entry_table_items[entry_idx].filepath()[0]; + let file = expand_home(&PathBuf::from(popup_entry.clone())); let object: OsString = popup_entry.into(); - app::open_connected_file(cfg, &object)?; + if file.is_file() { + app::open_connected_file(cfg, &object)?; + self.close_popup(); + } else { + self.open_popup( + PopupKind::MessageError, + Some("No valid file path: "), + Some(object.to_str().unwrap()), + None, + )?; + } } else { eprintln!("Unable to find ressource to open"); }; // run command to open file/Url - self.close_popup(); Ok(()) } -- cgit v1.2.3