6 use std::sync::atomic::{AtomicBool, Ordering};
8 static USED_ARGSFILE_FEATURE: AtomicBool = AtomicBool::new(false);
10 pub fn used_unstable_argsfile() -> bool {
11 USED_ARGSFILE_FEATURE.load(Ordering::Relaxed)
14 pub fn arg_expand(arg: String) -> Result<Vec<String>, Error> {
15 if arg.starts_with("@") {
17 let file = match fs::read_to_string(path) {
19 USED_ARGSFILE_FEATURE.store(true, Ordering::Relaxed);
22 Err(ref err) if err.kind() == io::ErrorKind::InvalidData => {
23 return Err(Error::Utf8Error(Some(path.to_string())));
25 Err(err) => return Err(Error::IOError(path.to_string(), err)),
27 Ok(file.lines().map(ToString::to_string).collect())
35 Utf8Error(Option<String>),
36 IOError(String, io::Error),
39 impl fmt::Display for Error {
40 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
42 Error::Utf8Error(None) => write!(fmt, "Utf8 error"),
43 Error::Utf8Error(Some(path)) => write!(fmt, "Utf8 error in {}", path),
44 Error::IOError(path, err) => write!(fmt, "IO Error: {}: {}", path, err),
49 impl error::Error for Error {
50 fn description(&self) -> &'static str {