如何在Rust中获取std :: process :: Command后面的命令?

问题描述 投票:0回答:1

我正在传递std::process::Command的实例。在执行命令之前,我想记录整个命令。例如,如果给我一个像这样构造的std::process::Command实例:

command

我想写一条类似的日志消息:

let command = Command::new("sh")
    .arg("-c")
    .arg("echo hello")

尽管API看起来非常有限。有没有办法做到这一点?

rust
1个回答
0
投票

Executing command: 'sh' '-c' 'echo hello'

Debug is implemented for Command

输出:Debug

© www.soinside.com 2019 - 2024. All rights reserved.