MCPcopy Create free account
hub / github.com/cargo-lambda/cargo-lambda / silent_command

Function silent_command

crates/cargo-lambda-interactive/src/command.rs:22–44  ·  view source on GitHub ↗

Run a command without producing any output in STDOUT and STDERR

(cmd: &str, args: &[&str])

Source from the content-addressed store, hash-verified

20
21/// Run a command without producing any output in STDOUT and STDERR
22pub async fn silent_command(cmd: &str, args: &[&str]) -> Result<(), CommandError> {
23 let child = new_command(cmd)
24 .args(args)
25 .stdout(Stdio::piped())
26 .stderr(Stdio::piped())
27 .spawn();
28 let Ok(mut child) = child else {
29 return Err(capture_error(cmd, args, None, Some(child.err().unwrap())).await);
30 };
31
32 let result = child.wait().await;
33 let Ok(result) = result else {
34 return Err(capture_error(cmd, args, Some(&mut child), None).await);
35 };
36
37 tracing::trace!(%result);
38
39 if result.success() {
40 Ok(())
41 } else {
42 Err(capture_error(cmd, args, Some(&mut child), None).await)
43 }
44}
45
46async fn capture_error(
47 cmd: &str,

Callers 2

install_target_componentFunction · 0.85
installMethod · 0.85

Calls 2

new_commandFunction · 0.85
capture_errorFunction · 0.85

Tested by

no test coverage detected