summaryrefslogtreecommitdiffstats
path: root/src/args.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/args.rs')
-rw-r--r--src/args.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/args.rs b/src/args.rs
index aca9bcd5..302e330e 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -80,6 +80,7 @@ pub struct Args {
types: Types,
with_filename: bool,
search_zip_files: bool,
+ preprocessor: Option<PathBuf>,
stats: bool
}
@@ -288,6 +289,7 @@ impl Args {
.quiet(self.quiet)
.text(self.text)
.search_zip_files(self.search_zip_files)
+ .preprocessor(self.preprocessor.clone())
.build()
}
@@ -429,6 +431,7 @@ impl<'a> ArgMatches<'a> {
types: self.types()?,
with_filename: with_filename,
search_zip_files: self.is_present("search-zip"),
+ preprocessor: self.preprocessor(),
stats: self.stats()
};
if args.mmap {
@@ -722,6 +725,19 @@ impl<'a> ArgMatches<'a> {
}
}
+ /// Returns the preprocessor command
+ fn preprocessor(&self) -> Option<PathBuf> {
+ if let Some(path) = self.value_of_os("pre") {
+ if path.is_empty() {
+ None
+ } else {
+ Some(Path::new(path).to_path_buf())
+ }
+ } else {
+ None
+ }
+ }
+
/// Returns the unescaped path separator in UTF-8 bytes.
fn path_separator(&self) -> Result<Option<u8>> {
match self.value_of_lossy("path-separator") {