Run a command and return captured stdout as UTF-8 string.
(cmd: &str, args: &[&str])
| 27 | |
| 28 | /// Run a command and return captured stdout as UTF-8 string. |
| 29 | fn run_capture(cmd: &str, args: &[&str]) -> Result<String> { |
| 30 | let out = Command::new(cmd) |
| 31 | .args(args) |
| 32 | .stdin(Stdio::null()) |
| 33 | .output() |
| 34 | .with_context(|| format!("Failed to start {cmd}"))?; |
| 35 | if !out.status.success() { |
| 36 | return Err(anyhow!("Command failed: {cmd} {args:?} (exit {})", out.status)); |
| 37 | } |
| 38 | Ok(String::from_utf8(out.stdout)?) |
| 39 | } |
| 40 | |
| 41 | fn main() -> Result<()> { |
| 42 | let out_dir = "src/sdk/client_api"; |