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

View File

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

View File

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

View File

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