MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / run_inherit

Function run_inherit

tools/generate-client-api/src/main.rs:11–26  ·  view source on GitHub ↗

Run a command inheriting stdio; error if it fails.

(cmd: impl AsRef<OsStr>, args: &[&str], cwd: Option<&Path>)

Source from the content-addressed store, hash-verified

9
10/// Run a command inheriting stdio; error if it fails.
11fn run_inherit(cmd: impl AsRef<OsStr>, args: &[&str], cwd: Option<&Path>) -> Result<()> {
12 let cmd = cmd.as_ref();
13 let mut c = Command::new(cmd);
14 if let Some(cwd) = cwd {
15 c.current_dir(cwd);
16 }
17 let status = c
18 .args(args)
19 .stdin(Stdio::null())
20 .status()
21 .with_context(|| format!("Failed to start {cmd:?}"))?;
22 if !status.success() {
23 return Err(anyhow!("Command failed: {cmd:?} {args:?} (exit {status})"));
24 }
25 Ok(())
26}
27
28/// Run a command and return captured stdout as UTF-8 string.
29fn run_capture(cmd: &str, args: &[&str]) -> Result<String> {

Callers 1

mainFunction · 0.70

Calls 7

statusMethod · 0.80
stdinMethod · 0.80
successMethod · 0.80
newFunction · 0.50
ErrFunction · 0.50
OkFunction · 0.50
as_refMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…