diff options
| author | lukeflo | 2025-02-19 21:42:57 +0100 |
|---|---|---|
| committer | lukeflo | 2025-02-19 21:42:57 +0100 |
| commit | f60be8b6b1e5987613081c9ad8d63a26a1a1bac9 (patch) | |
| tree | ccab6a52dd2112f070e5ce6526bd942b54be2806 /src | |
| parent | dc5ded8160177864963a31476c2a7afe8ca8e834 (diff) | |
| download | bibiman-f60be8b6b1e5987613081c9ad8d63a26a1a1bac9.tar.gz bibiman-f60be8b6b1e5987613081c9ad8d63a26a1a1bac9.zip | |
remove some comments, update README
Diffstat (limited to 'src')
| -rw-r--r-- | src/app.rs | 22 | ||||
| -rw-r--r-- | src/cliargs.rs | 7 |
2 files changed, 9 insertions, 20 deletions
@@ -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<PathBuf>) -> Vec<PathBuf> { let mut files: Vec<PathBuf> = 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 |
