From f60be8b6b1e5987613081c9ad8d63a26a1a1bac9 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Wed, 19 Feb 2025 21:42:57 +0100 Subject: remove some comments, update README --- src/app.rs | 22 ++-------------------- src/cliargs.rs | 7 +++++++ 2 files changed, 9 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/app.rs b/src/app.rs index e03f8d7..55f49de 100644 --- a/src/app.rs +++ b/src/app.rs @@ -364,15 +364,6 @@ impl App { pub fn open_connected_file(cfg: &BibiConfig, file: &OsStr) -> Result<()> { // Build command to execute pdf-reader. 'xdg-open' is Linux standard - // TODO: make custom opener command possible through config - // let cmd = { - // match std::env::consts::OS { - // "linux" => String::from("xdg-open"), - // "macos" => String::from("open"), - // "windows" => String::from("start"), - // _ => panic!("Couldn't detect OS for setting correct opener"), - // } - // }; let cmd = match &cfg.general.pdf_opener { Some(c) => c, None => &select_opener(), @@ -397,15 +388,6 @@ pub fn open_connected_file(cfg: &BibiConfig, file: &OsStr) -> Result<()> { pub fn open_connected_link(cfg: &BibiConfig, link: &str) -> Result<()> { // Build command to execute pdf-reader. 'xdg-open' is Linux standard - // TODO: make custom opener command possible through config - // let cmd = { - // match std::env::consts::OS { - // "linux" => String::from("xdg-open"), - // "macos" => String::from("open"), - // "windows" => String::from("start"), - // _ => panic!("Couldn't detect OS for setting correct opener"), - // } - // }; let cmd = match &cfg.general.url_opener { Some(c) => c, None => &select_opener(), @@ -433,8 +415,8 @@ pub fn prepare_weblink(url: &str) -> String { } } -fn expand_home(path: &PathBuf) -> PathBuf { - // let path = PathBuf::from(path); +/// Expand leading tilde (`~`) to `/home/user` +pub fn expand_home(path: &PathBuf) -> PathBuf { if path.starts_with("~") { let mut home = dirs::home_dir().unwrap(); let path = path.strip_prefix("~").unwrap(); diff --git a/src/cliargs.rs b/src/cliargs.rs index 895f116..bb3c8d1 100644 --- a/src/cliargs.rs +++ b/src/cliargs.rs @@ -23,6 +23,7 @@ use std::env; use std::path::PathBuf; use walkdir::WalkDir; +use crate::app; use crate::tui::colors::AppColors; // struct for CLIArgs @@ -76,6 +77,12 @@ pub fn parse_files(args: Vec) -> Vec { let mut files: Vec = Vec::new(); // If pos arg is file, just push it to path vec for i in args { + // Expand tilde to /home/user + let i = if i.starts_with("~") { + app::expand_home(&i) + } else { + i + }; if i.is_file() { files.push(i); // If pos arg is dir, walk dir and collect bibfiles -- cgit v1.2.3