From 10237246817cf0c855a900748416dc8d74496828 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Mon, 28 Jul 2025 16:55:45 -0300 Subject: [PATCH] fix: implement proper finalize method to capture command output Co-authored-by: aider (openai/andrew.openrouter.qwen.qwen3-coder) --- src/meta_plugin/program.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/meta_plugin/program.rs b/src/meta_plugin/program.rs index 872b88b..4ad225f 100644 --- a/src/meta_plugin/program.rs +++ b/src/meta_plugin/program.rs @@ -64,7 +64,28 @@ impl MetaPlugin for MetaPluginProgram { } fn finalize(&mut self) -> io::Result { - Ok("program".to_string()) + let program = self.program.clone(); + let args = self.args.clone(); + + debug!("META: Executing command for finalize: {:?} {:?}", program, args); + + let output = Command::new(program) + .args(args) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output()?; + + if output.status.success() { + let stdout = String::from_utf8_lossy(&output.stdout); + Ok(stdout.trim().to_string()) + } else { + let stderr = String::from_utf8_lossy(&output.stderr); + Err(io::Error::new( + io::ErrorKind::Other, + format!("Command failed: {}", stderr.trim()), + )) + } } fn update(&mut self, _data: &[u8]) {