summaryrefslogtreecommitdiffstats
path: root/src/args.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2017-02-02 15:29:50 +0100
committerAndrew Gallant <jamslam@gmail.com>2017-03-12 21:21:28 -0400
commitd352b792944af6dc5d818b1ed3119f0914dfce38 (patch)
tree8f199062da76cdee8c7e5558ea9f8795e2160200 /src/args.rs
parent23aec586696afb5d3cda1081d63f9641caad1045 (diff)
Add new -M/--max-columns option.
This permits setting the maximum line width with respect to the number of bytes in a line. Omitted lines (whether part of a match, replacement or context) are replaced with a message stating that the line was elided. Fixes #129
Diffstat (limited to 'src/args.rs')
-rw-r--r--src/args.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/args.rs b/src/args.rs
index cc48b7ad..148ae8b7 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -56,6 +56,7 @@ pub struct Args {
invert_match: bool,
line_number: bool,
line_per_match: bool,
+ max_columns: Option<usize>,
max_count: Option<u64>,
max_filesize: Option<u64>,
maxdepth: Option<usize>,
@@ -156,7 +157,8 @@ impl Args {
.line_per_match(self.line_per_match)
.null(self.null)
.path_separator(self.path_separator)
- .with_filename(self.with_filename);
+ .with_filename(self.with_filename)
+ .max_columns(self.max_columns);
if let Some(ref rep) = self.replace {
p = p.replace(rep.clone());
}
@@ -348,6 +350,7 @@ impl<'a> ArgMatches<'a> {
invert_match: self.is_present("invert-match"),
line_number: line_number,
line_per_match: self.is_present("vimgrep"),
+ max_columns: try!(self.usize_of("max-columns")),
max_count: try!(self.usize_of("max-count")).map(|max| max as u64),
max_filesize: try!(self.max_filesize()),
maxdepth: try!(self.usize_of("maxdepth")),