From d443843d352d740b895c4d622eb9af9567aa7423 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 17 Feb 2025 20:55:46 +0100 Subject: 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 --- src/config.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/config.rs') 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, - pub editor: String, + pub editor: Option, } impl BibiConfig { - pub fn new(args: &mut CLIArgs) -> Result { + pub fn default(args: &CLIArgs) -> Self { + Self { + general: General { + bibfiles: args.pos_args.clone(), + editor: None, + }, + } + } + + pub fn new(args: &CLIArgs) -> Result { 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() } -- cgit v1.2.3