CLI: add fonts download subcommand to fetch assets
Expose a `docx-mcp fonts download` subcommand that runs the existing `download_fonts.sh` helper, so users can fetch the embedded fonts via the binary. Keeps existing flags intact and avoids build-time network coupling.
This commit is contained in:
+29
-1
@@ -1,7 +1,7 @@
|
||||
use anyhow::Result;
|
||||
use mcp_server::{Server, ServerBuilder, ServerOptions};
|
||||
use mcp_core::ToolManager;
|
||||
use tracing::info;
|
||||
use tracing::{info, warn};
|
||||
use tracing_subscriber::{EnvFilter, fmt, prelude::*};
|
||||
use clap::Parser;
|
||||
|
||||
@@ -16,6 +16,7 @@ mod security;
|
||||
mod fonts;
|
||||
|
||||
use docx_tools::DocxToolsProvider;
|
||||
use std::process::Command;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
@@ -26,6 +27,33 @@ async fn main() -> Result<()> {
|
||||
|
||||
// Parse command line arguments (which also includes environment variables)
|
||||
let args = security::Args::parse();
|
||||
|
||||
// Handle top-level subcommands that should run and exit
|
||||
if let Some(cmd) = &args.command {
|
||||
match cmd {
|
||||
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");
|
||||
}
|
||||
info!("Fonts downloaded successfully");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let security_config = security::SecurityConfig::from_args(args);
|
||||
info!("Starting DOCX MCP Server - Security: {}", security_config.get_summary());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user