Add /dev/null support in Windows

This commit is contained in:
Fabrice Reix 2021-10-08 08:27:20 +02:00 committed by Fabrice Reix
parent 24932394e2
commit 89453db871

View File

@ -28,6 +28,16 @@ use std::io::{BufRead, BufReader};
use std::path::{Path, PathBuf};
use std::time::Duration;
#[cfg(target_family = "unix")]
pub fn dev_null() -> String {
"/dev/null".to_string()
}
#[cfg(target_family = "windows")]
pub fn dev_null() -> String {
"nul".to_string()
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CliOptions {
pub color: bool,
@ -323,7 +333,7 @@ pub fn parse_options(matches: ArgMatches) -> Result<CliOptions, CliError> {
let output = if let Some(filename) = matches.value_of("output") {
Some(filename.to_string())
} else if matches.is_present("test") {
Some("/dev/null".to_string())
Some(dev_null())
} else {
None
};