CLI: inline font download + checksum verification

- Add `fonts download` and `fonts verify` subcommands
- Implement Rust-based downloader (ureq + tar + flate2) with pinned sources
- Verify SHA-256 for Liberation and Noto Sans TTFs for reproducibility
- Keep binary behind `build-bin` feature; library build unaffected
This commit is contained in:
Andy
2025-08-11 15:04:47 +08:00
parent 98c056c3d9
commit d4ebdbf6a9
6 changed files with 170 additions and 38 deletions
+6 -12
View File
@@ -34,21 +34,15 @@ async fn main() -> Result<()> {
security::CliCommand::Fonts { action } => {
match action {
security::FontsAction::Download => {
info!("Downloading fonts via embedded helper...");
// Prefer the script if available; otherwise, fetch directly in the future
let script_path = "./download_fonts.sh";
if !std::path::Path::new(script_path).exists() {
warn!("download_fonts.sh not found; please run it manually or pull latest");
anyhow::bail!("download_fonts.sh not found");
}
let status = Command::new(script_path).status()?;
if !status.success() {
anyhow::bail!("Font download helper failed");
}
docx_mcp::fonts_cli::download_fonts_blocking()?;
info!("Fonts downloaded successfully");
return Ok(());
}
security::FontsAction::Verify => {
docx_mcp::fonts_cli::verify_fonts_blocking()?;
info!("Fonts verified successfully");
return Ok(());
}
}
}
}