diff options
author | Balaji Sivaraman <balaji@balajisivaraman.com> | 2018-02-21 22:16:45 +0530 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-03-10 10:15:19 -0500 |
commit | b006943c01561a4ae5b928081d1bb4087b599e19 (patch) | |
tree | 88c402f4edc91b808260c9c7c9ea4e0a5790c089 /src/args.rs | |
parent | 91d0756f62790356012d692a7b340df92b54beac (diff) |
search: add -b/--byte-offset flag
This commit adds support for printing 0-based byte offset before each
line. We handle corner cases such as `-o/--only-matching` and
`-C/--context` as well.
Closes #812
Diffstat (limited to 'src/args.rs')
-rw-r--r-- | src/args.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/args.rs b/src/args.rs index 0461261b..b8714deb 100644 --- a/src/args.rs +++ b/src/args.rs @@ -35,6 +35,7 @@ pub struct Args { paths: Vec<PathBuf>, after_context: usize, before_context: usize, + byte_offset: bool, color_choice: termcolor::ColorChoice, colors: ColorSpecs, column: bool, @@ -259,6 +260,7 @@ impl Args { WorkerBuilder::new(self.grep()) .after_context(self.after_context) .before_context(self.before_context) + .byte_offset(self.byte_offset) .count(self.count) .encoding(self.encoding) .files_with_matches(self.files_with_matches) @@ -361,6 +363,7 @@ impl<'a> ArgMatches<'a> { paths: paths, after_context: after_context, before_context: before_context, + byte_offset: self.is_present("byte-offset"), color_choice: self.color_choice(), colors: self.color_specs()?, column: self.column(), |