use crate::params::{ImpactAllParams, ImpactParams};
use rmcp::ErrorData as McpError;
use rmcp::model::CallToolResult;
use super::{push_str_flag, run_tool};
pub async fn run_impact(binary: &str, params: ImpactParams) -> Result<CallToolResult, McpError> {
let args = build_impact_args(¶ms);
run_tool(binary, "impact", &args).await
}
pub async fn run_impact_all(
binary: &str,
params: ImpactAllParams,
) -> Result<CallToolResult, McpError> {
let args = build_impact_all_args(¶ms);
run_tool(binary, "impact_all", &args).await
}
pub fn build_impact_args(params: &ImpactParams) -> Vec<String> {
let mut args = vec![
"impact".to_string(),
"--format".to_string(),
"json".to_string(),
"--quiet".to_string(),
];
push_str_flag(&mut args, "--root", params.root.as_deref());
args
}
pub fn build_impact_all_args(params: &ImpactAllParams) -> Vec<String> {
let mut args = vec![
"impact".to_string(),
"--all".to_string(),
"--format".to_string(),
"json".to_string(),
"--quiet".to_string(),
];
push_str_flag(&mut args, "--sort", params.sort.as_deref());
if let Some(limit) = params.limit {
args.push("--limit".to_string());
args.push(limit.to_string());
}
args
}