MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / execute_repl

Function execute_repl

claw-code/rust/crates/tools/src/lib.rs:2376–2396  ·  view source on GitHub ↗
(input: ReplInput)

Source from the content-addressed store, hash-verified

2374}
2375
2376fn execute_repl(input: ReplInput) -> Result<ReplOutput, String> {
2377 if input.code.trim().is_empty() {
2378 return Err(String::from("code must not be empty"));
2379 }
2380 let _ = input.timeout_ms;
2381 let runtime = resolve_repl_runtime(&input.language)?;
2382 let started = Instant::now();
2383 let output = Command::new(runtime.program)
2384 .args(runtime.args)
2385 .arg(&input.code)
2386 .output()
2387 .map_err(|error| error.to_string())?;
2388
2389 Ok(ReplOutput {
2390 language: input.language,
2391 stdout: String::from_utf8_lossy(&output.stdout).into_owned(),
2392 stderr: String::from_utf8_lossy(&output.stderr).into_owned(),
2393 exit_code: output.status.code().unwrap_or(1),
2394 duration_ms: started.elapsed().as_millis(),
2395 })
2396}
2397
2398struct ReplRuntime {
2399 program: &'static str,

Callers 1

run_replFunction · 0.85

Calls 1

resolve_repl_runtimeFunction · 0.85

Tested by

no test coverage detected