printer: add support for line number alignment

Closes #544
This commit is contained in:
Balaji Sivaraman
2018-01-01 19:30:31 +05:30
committed by Andrew Gallant
parent 5e73075ef5
commit ba1023e1e4
7 changed files with 69 additions and 3 deletions

View File

@@ -54,6 +54,7 @@ pub struct Args {
invert_match: bool,
line_number: bool,
line_per_match: bool,
line_number_width: Option<usize>,
max_columns: Option<usize>,
max_count: Option<u64>,
max_filesize: Option<u64>,
@@ -144,7 +145,8 @@ impl Args {
.only_matching(self.only_matching)
.path_separator(self.path_separator)
.with_filename(self.with_filename)
.max_columns(self.max_columns);
.max_columns(self.max_columns)
.line_number_width(self.line_number_width);
if let Some(ref rep) = self.replace {
p = p.replace(rep.clone());
}
@@ -336,6 +338,7 @@ impl<'a> ArgMatches<'a> {
ignore_files: self.ignore_files(),
invert_match: self.is_present("invert-match"),
line_number: line_number,
line_number_width: try!(self.usize_of("line-number-width")),
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),