summaryrefslogtreecommitdiffstats
path: root/src/args.rs
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2016-09-24 19:23:19 -0400
committerAndrew Gallant <jamslam@gmail.com>2016-09-24 19:24:24 -0400
commita6e3cab65a4e0b8dc14473eb83b10eaff2e7848d (patch)
tree236f764cb1a157fa6a698b3c7dec6a1878b66e2f /src/args.rs
parent7b860affbeb015aa0298a95b1e23eb8db7d181cc (diff)
Add --no-filename flag.
When this flag is set, a filename is never shown for a match. Closes #20
Diffstat (limited to 'src/args.rs')
-rw-r--r--src/args.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/args.rs b/src/args.rs
index 13ed6381..ea1bcba4 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -114,6 +114,10 @@ Less common options:
Prefix each match with the file name that contains it. This is the
default when more than one file is searched.
+ --no-filename
+ Never show the filename for a match. This is the default when
+ one file is searched.
+
--heading
Show the file name above clusters of matches from each file.
This is the default mode at a tty.
@@ -203,6 +207,7 @@ pub struct RawArgs {
flag_no_ignore_parent: bool,
flag_no_line_number: bool,
flag_no_mmap: bool,
+ flag_no_filename: bool,
flag_pretty: bool,
flag_quiet: bool,
flag_regexp: Vec<String>,
@@ -321,10 +326,13 @@ impl RawArgs {
self.flag_color == "always"
};
let eol = b'\n';
+
let mut with_filename = self.flag_with_filename;
if !with_filename {
with_filename = paths.len() > 1 || paths[0].is_dir();
}
+ with_filename = with_filename && !self.flag_no_filename;
+
let mut btypes = TypesBuilder::new();
btypes.add_defaults();
try!(self.add_types(&mut btypes));