1
use std::io;
2
use std::process::Command;
3
use std::process::ExitStatus;
4

            
5
use log::trace;
6

            
7
/// Runs the given command and logs the command line before executing it, returning the exit status.
8
pub fn traced_command(command: &mut Command) -> io::Result<ExitStatus> {
9
    trace!(
10
        "{} {}",
11
        command.get_program().to_string_lossy(),
12
        command
13
            .get_args()
14
            .map(|arg| arg.to_string_lossy())
15
            .collect::<Vec<_>>()
16
            .join(" ")
17
    );
18
    command.status()
19
}