process - 如何将 std::process::Command 转换为命令行字符串?
问题描述
例如:
let mut com = std::process::Command::new("ProgramA");
com.env("ENV_1", "VALUE_1")
.arg("-a")
.arg("foo")
.arg("-b")
.arg("--argument=bar");
// Get the command line string somehow here.
com.output().unwrap();
这将产生一个与该命令行"ProgramA" -a foo -b "--argument=with space"
关联的进程。
有没有办法把它从com
物体中取出来?
解决方案
原来是Command
工具Debug
;这会给我想要的结果:
let answer = format!("{:?}", com);
推荐阅读
- mailkit - 搜索/GetMessage 错误“System.IO.IOException:无法从传输连接中读取数据”
- c# - 如何将字典中的重复值合并为一个值
- datatables - 试图对数据表进行求和,但它只是第一页的求和
- c# - 我的发送函数(套接字库:system.net & system.net.sockets)有一些错误
- r - 在R中划分按区域分组的两列
- python - 如何使用 websocket 每 3 秒发送一次 JSON [Python 服务器,js 客户端]
- kubernetes - Rook Ceph Operator 在检查集群状态时挂起
- c# - 如何使用带有 .net core 2.2 的实例 api 将全局配置选项添加到 Automapper v8
- ios - 如何在使用 iOS 13 中新的字体管理功能时限制对字体的访问?
- swift - 无法从 Userdefaults 访问数据 - Swfit