starting phase 5; clap cli
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct Config {
|
||||
@@ -28,6 +29,20 @@ impl Default for Config {
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn load(path: &Path) -> anyhow::Result<Self> {
|
||||
if path.exists() {
|
||||
let contents = std::fs::read_to_string(path)?;
|
||||
let config: Config = serde_json::from_str(&contents)?;
|
||||
tracing::info!("Loaded config from {}", path.display());
|
||||
Ok(config)
|
||||
} else {
|
||||
tracing::warn!("Config file {} not found, using defaults", path.display());
|
||||
Ok(Self::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct MetadataResponse {
|
||||
#[serde(default)]
|
||||
|
||||
Reference in New Issue
Block a user