hooked_config/config/
mod.rs1use std::{fs::read_to_string, path::Path};
4
5use {
6 color_eyre::Result,
7 serde::{Deserialize, Serialize},
8};
9
10mod exit_action;
11mod general;
12mod pre_commit;
13mod task;
14
15pub use exit_action::*;
16pub use general::*;
17pub use pre_commit::*;
18pub use task::*;
19
20#[derive(Debug, Default, Deserialize, Serialize)]
22#[serde(default, deny_unknown_fields)]
23pub struct Config {
24 pub general: General,
26
27 pub pre_commit: Vec<PreCommit>,
29}
30
31impl Config {
32 pub fn from_toml_file<P>(file: P) -> Result<Self>
34 where
35 P: AsRef<Path>,
36 {
37 toml::from_str(&read_to_string(file)?).map_err(Into::into)
38 }
39}