elif_core/
config.rs

1use serde::{Deserialize, Serialize};
2use std::path::PathBuf;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct ProjectConfig {
6    pub name: String,
7    pub version: String,
8    pub database: DatabaseConfig,
9    pub output: OutputConfig,
10}
11
12#[derive(Debug, Clone, Serialize, Deserialize)]
13pub struct DatabaseConfig {
14    pub url_env: String,
15    pub migrations_dir: String,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct OutputConfig {
20    pub openapi_file: String,
21    pub map_file: String,
22}
23
24impl ProjectConfig {
25    pub fn load(path: &PathBuf) -> Result<Self, crate::ElifError> {
26        let content = std::fs::read_to_string(path)?;
27        let config = serde_yaml::from_str(&content)?;
28        Ok(config)
29    }
30    
31    pub fn manifest_path() -> PathBuf {
32        PathBuf::from(".elif/manifest.yaml")
33    }
34    
35    pub fn errors_path() -> PathBuf {
36        PathBuf::from(".elif/errors.yaml")
37    }
38    
39    pub fn policies_path() -> PathBuf {
40        PathBuf::from(".elif/policies.yaml")
41    }
42}