use std::fs;
use std::io;
use std::path::{Path, PathBuf};
const SKILL_TEMPLATE: &str = include_str!("templates/skill.md");
pub fn write_skill(skills_dir: &Path) -> io::Result<PathBuf> {
let target = skills_dir.join("rust-doctor");
fs::create_dir_all(&target)?;
let skill_path = target.join("SKILL.md");
fs::write(&skill_path, SKILL_TEMPLATE)?;
Ok(skill_path)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn template_is_not_empty() {
assert!(!SKILL_TEMPLATE.is_empty());
assert!(SKILL_TEMPLATE.contains("rust-doctor"));
}
#[test]
fn writes_skill_file() {
let dir = tempfile::tempdir().unwrap();
let path = write_skill(dir.path()).unwrap();
assert!(path.exists());
assert!(path.ends_with("rust-doctor/SKILL.md"));
let content = fs::read_to_string(&path).unwrap();
assert!(content.contains("name: rust-doctor"));
}
}