From 6e133b25e02edba228c488a4239334885b5ebc85 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 28 Nov 2021 16:37:04 +0100 Subject: config: add way for setting pandoc default options and update Cargo.lock --- src/config.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 53922b0..9b95f9a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use log::debug; use serde::{Deserialize, Serialize}; @@ -7,6 +9,21 @@ pub struct Config { pub book: BookConfig, #[serde(default)] pub build: BuildConfig, + #[serde(default)] + pub pandoc: HashMap, +} + +impl Config { + pub fn new(config_file: &str) -> Result { + let mut s = config::Config::default(); + + debug!("Parsing config file: {}", config_file); + s.merge(config::File::with_name(config_file))?; + debug!("Parsing config from environment"); + s.merge(config::Environment::with_prefix("PANDOC_DOCBOOK").separator("_"))?; + + s.try_into() + } } #[derive(Debug, Clone, Deserialize, Serialize)] @@ -44,16 +61,3 @@ impl Default for BuildConfig { fn default_build_dir() -> String { "pdbook".to_string() } - -impl Config { - pub fn new(config_file: &str) -> Result { - let mut s = config::Config::default(); - - debug!("Parsing config file: {}", config_file); - s.merge(config::File::with_name(config_file))?; - debug!("Parsing config from environment"); - s.merge(config::Environment::with_prefix("PANDOC_DOCBOOK").separator("_"))?; - - s.try_into() - } -} -- cgit v1.2.3