aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorlukeflo2025-02-17 20:55:46 +0100
committerlukeflo2025-02-17 20:55:46 +0100
commitd443843d352d740b895c4d622eb9af9567aa7423 (patch)
tree5b61ec01b2d54461c423b97e2a702e7ec7daded9 /src/config.rs
parent059591a1be6b887eaca9b114fdb5b350a65bae43 (diff)
downloadbibiman-d443843d352d740b895c4d622eb9af9567aa7423.tar.gz
bibiman-d443843d352d740b895c4d622eb9af9567aa7423.zip
improve file handling
+ If config file **and** CLI args have different files/dirs, concat them and open all + Adapt UI to show which files are choosen + TODO: Flag for ignoring config file
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/config.rs b/src/config.rs
index 2ef296a..a80cc13 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -30,16 +30,25 @@ pub struct BibiConfig {
#[derive(Debug, Clone, Deserialize)]
pub struct General {
pub bibfiles: Vec<PathBuf>,
- pub editor: String,
+ pub editor: Option<String>,
}
impl BibiConfig {
- pub fn new(args: &mut CLIArgs) -> Result<Self, ConfigError> {
+ pub fn default(args: &CLIArgs) -> Self {
+ Self {
+ general: General {
+ bibfiles: args.pos_args.clone(),
+ editor: None,
+ },
+ }
+ }
+
+ pub fn new(args: &CLIArgs) -> Result<Self, ConfigError> {
let mut cfg = config::Config::builder();
cfg = cfg.add_source(
config::File::from(args.cfg_path.clone())
.format(FileFormat::Toml)
- .required(true),
+ .required(false),
);
cfg.build()?.try_deserialize()
}