MCPcopy Create free account
hub / github.com/bitcoindevkit/bdk-cli / run_cmd_with_args

Function run_cmd_with_args

tests/integration.rs:43–57  ·  view source on GitHub ↗
(cmd: &str, args: &[&str])

Source from the content-addressed store, hash-verified

41 // Runs a system command with given args
42 #[allow(dead_code)]
43 fn run_cmd_with_args(cmd: &str, args: &[&str]) -> Result<serde_json::Value, IntTestError> {
44 let output = Command::new(cmd).args(args).output().unwrap();
45 let mut value = output.stdout;
46 let error = output.stderr;
47 if value.is_empty() {
48 return Err(IntTestError::CmdExec(String::from_utf8(error).unwrap()));
49 }
50 value.pop(); // remove `\n` at end
51 let output_string = std::str::from_utf8(&value).unwrap();
52 let json_value: serde_json::Value = match serde_json::from_str(output_string) {
53 Ok(value) => value,
54 Err(_) => json!(output_string), // bitcoin-cli will sometime return raw string
55 };
56 Ok(json_value)
57 }
58
59 // Helper Function
60 // Transforms a json value to string

Callers 3

wallet_execMethod · 0.85
key_execMethod · 0.85
node_execMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected