use std::path::Path;
use crate::error::{Result, SlokitError};
use super::Spec;
pub fn from_yaml(yaml: &str) -> Result<Spec> {
serde_norway::from_str(yaml).map_err(|e| SlokitError::Spec(e.to_string()))
}
pub fn from_path(path: &Path) -> Result<Spec> {
let contents = std::fs::read_to_string(path)
.map_err(|e| SlokitError::Spec(format!("reading {}: {e}", path.display())))?;
from_yaml(&contents)
}