aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorlukeflo2025-06-03 17:38:49 +0200
committerlukeflo2025-06-03 17:38:49 +0200
commitd7236320fde1994fa38c5d8b85c9f81f1559fff4 (patch)
treea3ff2fe49886d6bd33f0c6627d07669b377cbd22 /src/config.rs
parent1dcb24c381990bdead5fa3df2fb95d74b176a8c1 (diff)
parent201aecebcd7c85127df9c43da01fdafc3465e53e (diff)
downloadbibiman-d7236320fde1994fa38c5d8b85c9f81f1559fff4.tar.gz
bibiman-d7236320fde1994fa38c5d8b85c9f81f1559fff4.zip
Merge pull request 'pdf-by-filename' (#28) from pdf-by-filename-#27 into main
Implemented PDF dir: + now you can set a `pdf_path` variable in the config and throuch the CLI flag `--pdf-dir` + this dir will be searched recursivley for PDF files which mathc a citekey from the used `.bib` files and connects with them + every entry can have multiple PDFs with the citekey-basename in different subdirs + the bibfile itself will not be altered + additionally, i rewrote the internal popup code for easier contribution
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index d554c58..8d50d93 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<PathBuf>,
+ pub pdf_path: Option<PathBuf>,
}
/// 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_overwrite(&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);