File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 9
9
use anyhow:: { bail, Result } ;
10
10
use std:: process:: Command ;
11
11
12
- pub fn run_cmd ( mut cmd : Command ) -> Result < ( ) > {
12
+ fn print_cmd ( cmd : & Command ) {
13
13
println ! ( "Running: {}" , format!( "{cmd:?}" ) . replace( '"' , "" ) ) ;
14
+ }
15
+
16
+ pub fn run_cmd ( mut cmd : Command ) -> Result < ( ) > {
17
+ print_cmd ( & cmd) ;
14
18
let status = cmd. status ( ) . expect ( "failed to launch" ) ;
15
19
if status. success ( ) {
16
20
Ok ( ( ) )
17
21
} else {
18
22
bail ! ( "command failed: {status}" ) ;
19
23
}
20
24
}
25
+
26
+ pub fn get_cmd_stdout ( mut cmd : Command ) -> Result < Vec < u8 > > {
27
+ print_cmd ( & cmd) ;
28
+ let output = cmd. output ( ) . expect ( "failed to launch" ) ;
29
+ if output. status . success ( ) {
30
+ Ok ( output. stdout )
31
+ } else {
32
+ bail ! ( "command failed: {}" , output. status) ;
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments