Add config file configuration.

This commit is contained in:
Bauke 2022-11-01 13:38:52 +01:00
parent b386e59c3e
commit 4dab507636
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
4 changed files with 10 additions and 3 deletions

View File

@ -8,6 +8,9 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
#[serde(default, deny_unknown_fields)]
pub struct General {
/// Path to the Hooked configuration file.
pub config: PathBuf,
/// The directory to use for hooks.
pub directory: PathBuf,
}
@ -15,6 +18,7 @@ pub struct General {
impl Default for General {
fn default() -> Self {
Self {
config: PathBuf::from("Hooked.toml"),
directory: PathBuf::from("hooks"),
}
}

View File

@ -1,9 +1,10 @@
---
source: tests/parsing.rs
source: hooked-config/tests/parsing.rs
expression: config
---
Config {
general: General {
config: "Hooked.toml",
directory: "hooks",
},
pre_commit: [

View File

@ -1,9 +1,10 @@
---
source: tests/parsing.rs
source: hooked-config/tests/parsing.rs
expression: config
---
Config {
general: General {
config: "Hooked.toml",
directory: "hooked",
},
pre_commit: [

View File

@ -1,8 +1,9 @@
---
source: tests/serialize.rs
source: hooked-config/tests/serialize.rs
expression: to_string_pretty(&config).unwrap()
---
[general]
config = 'Hooked.toml'
directory = 'hooks'
[[pre_commit]]