From 28030fd0830478872be2b9e86b74e0c054a96111 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sat, 24 May 2025 17:31:33 +0200 Subject: implemented a workflow, but citekey matching still buggy --- src/config.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index d554c58..1532d31 100644 --- a/src/config.rs +++ b/src/config.rs @@ -51,6 +51,11 @@ const DEFAULT_CONFIG: &str = r##" ## Use absolute paths (~ for HOME works). Otherwise, loading might not work. # file_prefix = "/some/path/prefix" +## Path to folder (with subfolders) containing PDF files with the basename +## of the format "citekey.pdf". Other PDF basenames are not accepted. +## Use absolute paths (~ for HOME works). Otherwise, loading might not work. +# pdf_path = "/path/to/pdf/folder" + # [colors] ## Default values for dark-themed terminal ## Possible values are: @@ -84,6 +89,7 @@ pub struct General { pub pdf_opener: String, pub url_opener: String, pub file_prefix: Option, + pub pdf_path: Option, } /// Substruct [colors] in config.toml @@ -110,6 +116,7 @@ impl Default for BibiConfig { pdf_opener: select_opener(), url_opener: select_opener(), file_prefix: None, + pdf_path: None, }, colors: Colors { main_text_color: Color::Indexed(250), @@ -140,6 +147,14 @@ impl BibiConfig { Ok(cfg_file) } + /// overwright config values with values set explicitly through the + /// command line interface + pub fn cli_overwright(&mut self, args: &CLIArgs) { + if args.pdf_path.is_some() { + self.general.pdf_path = args.pdf_path.clone(); + } + } + /// Activates the default color scheme for light background terminals pub fn light_colors(&mut self) { self.colors.main_text_color = Color::Indexed(235); -- cgit v1.2.3 From c0dcbcd18a3fba111885fd0eaf8ef18f71cf693a Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 26 May 2025 14:55:21 +0200 Subject: some more doc strings --- src/cliargs.rs | 20 +++++++++++--------- src/config.rs | 2 +- src/main.rs | 2 +- src/tui/popup.rs | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 11 deletions(-) (limited to 'src/config.rs') diff --git a/src/cliargs.rs b/src/cliargs.rs index a9b12fd..c7a0eb1 100644 --- a/src/cliargs.rs +++ b/src/cliargs.rs @@ -56,7 +56,7 @@ impl CLIArgs { Short('v') | Long("version") => args.versionarg = true, Short('c') | Long("config-file") => args.cfg_path = Some(parser.value()?.parse()?), Long("light-terminal") => args.light_theme = true, - Long("merge-pdf-paths") => { + Long("pdf-dir") => { args.pdf_path = Some(parser.value()?.parse()?); } // Value(pos_arg) => parse_files(&mut args, pos_arg), @@ -126,14 +126,16 @@ POSITIONAL ARGS: Both can be passed multiple times FLAGS: - -h, --help Show this help and exit - -v, --version Show the version and exit - -c, --config-file Path to config file used for current session. - Takes precedence over standard config file. - --light-terminal Enable color mode for light terminal background - --merge-pdf-paths Merge PDF files named by citekey at the given path into - the `file` field of the entry matching the citekey - (might not work with citekeys containing special chars)", + -h, --help Show this help and exit + -v, --version Show the version and exit + -c, --config-file= Path to config file used for current session. + Takes precedence over standard config file. + --light-terminal= Enable color mode for light terminal background + --pdf-dir= Use PDF files named by citekey at the given path and its + subdirs as value for the `file` field of the entry matching + the citekey for the current session. + Does not overwrite or change the original file. + (might not work with citekeys containing special chars)", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"), ); diff --git a/src/config.rs b/src/config.rs index 1532d31..8d50d93 100644 --- a/src/config.rs +++ b/src/config.rs @@ -149,7 +149,7 @@ impl BibiConfig { /// overwright config values with values set explicitly through the /// command line interface - pub fn cli_overwright(&mut self, args: &CLIArgs) { + pub fn cli_overwrite(&mut self, args: &CLIArgs) { if args.pdf_path.is_some() { self.general.pdf_path = args.pdf_path.clone(); } diff --git a/src/main.rs b/src/main.rs index dd82c0f..add1f2e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,7 +59,7 @@ async fn main() -> Result<()> { BibiConfig::default() }; - cfg.cli_overwright(&parsed_args); + cfg.cli_overwrite(&parsed_args); init_error_hooks()?; diff --git a/src/tui/popup.rs b/src/tui/popup.rs index 2a6f18a..a0a61a4 100644 --- a/src/tui/popup.rs +++ b/src/tui/popup.rs @@ -26,11 +26,17 @@ use crate::config::BibiConfig; #[derive(Debug)] pub enum PopupKind { Help, + /// use for a confirmation message MessageConfirm, + /// use for a warning message MessageError, + /// open a resource connected to the entry OpenRes, + /// select file to append entry to AppendToFile, + /// append entry to a bibfile (selected in `AppendToFile` popup) AddEntry, + /// select an item of the current entry to yank to clipboard YankItem, } @@ -108,6 +114,14 @@ impl PopupArea { Text::from(helptext) } + /// Creates a popup message. The needed arguments are: + /// + /// - `message` as `str`: The message displayed in the popup. + /// - `object` as `str`: A possible object added to the message. E.g. the content + /// which gets copied to the clipboard. + /// - `msg_confirm` as `bool`: if `true` its a confirmation message displayed in + /// in the set `confirm_color` (default: green), if `false` its a warning + /// message displayed in the set `warn_color` (default: red). pub fn popup_message(&mut self, message: &str, object: &str, msg_confirm: bool) { if object.is_empty() { self.popup_message = message.to_owned(); @@ -122,6 +136,9 @@ impl PopupArea { self.is_popup = true; } + /// Opens a popup with a selectable list + /// + /// The list items are passed as argument of the kind `Vec`. pub fn popup_selection(&mut self, items: Vec) { self.popup_list = items; // self.popup_kind = Some(PopupKind::SelectRes); -- cgit v1.2.3