summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2018-04-23 19:57:22 -0400
committerAndrew Gallant <jamslam@gmail.com>2018-04-23 19:57:22 -0400
commitae6f8714912d522e8042701c30da43c6c667dfd3 (patch)
tree107c31e5239988888254622161660bf79d6bbb4c /src
parented059559cd465c32ee7b05b9ae46612c105a2bea (diff)
output: remove --line-number-width flag
This commit does what no software project has ever done before: we've outright removed a flag with no possible way to recapture its functionality. This flag presents numerous problems in that it never really worked well in the first place, and completely falls over when ripgrep uses the --no-heading output format. Well meaning users want ripgrep to fix this by getting into the alignment business by buffering all output, but that is a line that I refuse to cross. Fixes #795
Diffstat (limited to 'src')
-rw-r--r--src/app.rs30
-rw-r--r--src/args.rs5
-rw-r--r--src/printer.rs14
3 files changed, 1 insertions, 48 deletions
diff --git a/src/app.rs b/src/app.rs
index 2c3bfe43..2cb2c468 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -475,23 +475,6 @@ impl RGArg {
});
self
}
-
- /// Indicate that any value given to this argument should be a valid
- /// line number width. A valid line number width cannot start with `0`
- /// to maintain compatibility with future improvements that add support
- /// for padding character specifies.
- fn line_number_width(mut self) -> RGArg {
- self.claparg = self.claparg.validator(|val| {
- if val.starts_with("0") {
- Err(String::from(
- "Custom padding characters are currently not supported. \
- Please enter only a numeric value."))
- } else {
- val.parse::<usize>().map(|_| ()).map_err(|err| err.to_string())
- }
- });
- self
- }
}
// We add an extra space to long descriptions so that a black line is inserted
@@ -535,7 +518,6 @@ pub fn all_args_and_flags() -> Vec<RGArg> {
flag_ignore_file(&mut args);
flag_invert_match(&mut args);
flag_line_number(&mut args);
- flag_line_number_width(&mut args);
flag_line_regexp(&mut args);
flag_max_columns(&mut args);
flag_max_count(&mut args);
@@ -1100,18 +1082,6 @@ terminal.
args.push(arg);
}
-fn flag_line_number_width(args: &mut Vec<RGArg>) {
- const SHORT: &str = "Left pad line numbers up to NUM width.";
- const LONG: &str = long!("\
-Left pad line numbers up to NUM width. Space is used as the default padding
-character. This has no effect if --no-line-number is enabled.
-");
- let arg = RGArg::flag("line-number-width", "NUM")
- .help(SHORT).long_help(LONG)
- .line_number_width();
- args.push(arg);
-}
-
fn flag_line_regexp(args: &mut Vec<RGArg>) {
const SHORT: &str = "Only show matches surrounded by line boundaries.";
const LONG: &str = long!("\
diff --git a/src/args.rs b/src/args.rs
index 516a4d04..0c231d0f 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -56,7 +56,6 @@ 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>,
@@ -191,8 +190,7 @@ impl Args {
.only_matching(self.only_matching)
.path_separator(self.path_separator)
.with_filename(self.with_filename)
- .max_columns(self.max_columns)
- .line_number_width(self.line_number_width);
+ .max_columns(self.max_columns);
if let Some(ref rep) = self.replace {
p = p.replace(rep.clone());
}
@@ -401,7 +399,6 @@ 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: self.usize_of_nonzero("max-columns")?,
max_count: self.usize_of("max-count")?.map(|n| n as u64),
diff --git a/src/printer.rs b/src/printer.rs
index 840c7c9a..fce6858c 100644
--- a/src/printer.rs
+++ b/src/printer.rs
@@ -99,10 +99,6 @@ pub struct Printer<W> {
path_separator: Option<u8>,
/// Restrict lines to this many columns.
max_columns: Option<usize>,
- /// Width of line number displayed. If the number of digits in the
- /// line number is less than this, it is left padded with
- /// spaces.
- line_number_width: Option<usize>
}
impl<W: WriteColor> Printer<W> {
@@ -124,7 +120,6 @@ impl<W: WriteColor> Printer<W> {
colors: ColorSpecs::default(),
path_separator: None,
max_columns: None,
- line_number_width: None
}
}
@@ -213,12 +208,6 @@ impl<W: WriteColor> Printer<W> {
self
}
- /// Configure the width of the displayed line number
- pub fn line_number_width(mut self, line_number_width: Option<usize>) -> Printer<W> {
- self.line_number_width = line_number_width;
- self
- }
-
/// Returns true if and only if something has been printed.
pub fn has_printed(&self) -> bool {
self.has_printed
@@ -484,9 +473,6 @@ impl<W: WriteColor> Printer<W> {
fn line_number(&mut self, n: u64, sep: u8) {
let mut line_number = n.to_string();
- if let Some(width) = self.line_number_width {
- line_number = format!("{:>width$}", line_number, width = width);
- }
self.write_colored(line_number.as_bytes(), |colors| colors.line());
self.separator(&[sep]);
}