gdke/src/versioning.rs

19 lines
506 B
Rust
Raw Normal View History

2024-01-30 20:38:15 +00:00
use std::{
2024-02-12 10:09:16 +00:00
io::{BufRead, Cursor, Read},
2024-01-30 20:38:15 +00:00
path::Path,
process::{Command, Stdio},
};
2024-02-12 10:09:16 +00:00
pub fn check_gd_ver(exe: &Path) -> anyhow::Result<String> {
2024-01-30 20:38:15 +00:00
assert!(exe.exists());
let stdo = Command::new(exe)
2024-02-12 10:09:16 +00:00
.arg("--version")
// .stderr(Stdio::null())
2024-01-30 20:38:15 +00:00
.output()?;
2024-02-12 10:09:16 +00:00
let mut bufr = Cursor::new(stdo.stdout);
2024-02-12 10:09:16 +00:00
let mut out = String::new();
bufr.read_to_string(&mut out)
.map_err(|_| anyhow::anyhow!("unable to read version"))?;
Ok(out.trim().to_string())
2024-01-30 20:38:15 +00:00
}