fix: implement proper finalize method to capture command output
Co-authored-by: aider (openai/andrew.openrouter.qwen.qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -64,7 +64,28 @@ impl MetaPlugin for MetaPluginProgram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn finalize(&mut self) -> io::Result<String> {
|
fn finalize(&mut self) -> io::Result<String> {
|
||||||
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]) {
|
fn update(&mut self, _data: &[u8]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user