use anyhow::Result;
use std::path::Path;
pub fn copy_tree(src: &Path, dst: &Path) -> Result<()> {
std::fs::create_dir_all(dst)?;
for entry in std::fs::read_dir(src)? {
let entry = entry?;
let name = entry.file_name();
if name == ".git" {
continue;
}
let ft = entry.file_type()?;
if ft.is_symlink() {
eprintln!(
"warning: skipping symlink `{}` while copying skill",
entry.path().display()
);
continue;
}
let from = entry.path();
let to = dst.join(&name);
if ft.is_dir() {
copy_tree(&from, &to)?;
} else {
std::fs::copy(&from, &to)?;
}
}
Ok(())
}