use clap::{Error, ErrorKind};
use std::{io::BufRead, process::Command};
pub fn host_triple() -> String {
Command::new("rustc")
.arg("-vV")
.output()
.map_err(|err| err.to_string())
.and_then(|out| {
out.stdout
.lines()
.map_while(Result::ok)
.find_map(|line| line.strip_prefix("host: ").map(ToString::to_string))
.ok_or_else(|| "`rustc -vV` didn't have a line for `host`.".to_string())
})
.unwrap_or_else(|err| Error::with_description(&err, ErrorKind::Io).exit())
}