Run an `openshell` CLI command and return the result.
(args: &[&str])
| 142 | |
| 143 | /// Run an `openshell` CLI command and return the result. |
| 144 | async fn run_cli(args: &[&str]) -> CliResult { |
| 145 | let mut cmd = openshell_cmd(); |
| 146 | cmd.args(args).stdout(Stdio::piped()).stderr(Stdio::piped()); |
| 147 | |
| 148 | let output = cmd.output().await.expect("spawn openshell command"); |
| 149 | let stdout = String::from_utf8_lossy(&output.stdout).to_string(); |
| 150 | let stderr = String::from_utf8_lossy(&output.stderr).to_string(); |
| 151 | let combined = strip_ansi(&format!("{stdout}{stderr}")); |
| 152 | |
| 153 | CliResult { |
| 154 | success: output.status.success(), |
| 155 | output: combined, |
| 156 | exit_code: output.status.code(), |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /// Extract the policy version number from `policy get` output. |
| 161 | /// |
no test coverage detected