mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-11 14:30:24 +02:00
print hello for histogram
This commit is contained in:
@ -1354,7 +1354,8 @@ impl Flag for Histogram {
|
||||
|
||||
fn update(&self, v: FlagValue, args: &mut LowArgs) -> anyhow::Result<()> {
|
||||
let binsize = convert::usize(&v.unwrap_value())?;
|
||||
args.histogram = if binsize == 0 { None } else { Some(binsize) };
|
||||
args.histogram = binsize;
|
||||
args.mode.update(Mode::Search(SearchMode::Histogram));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -203,6 +203,7 @@ impl HiArgs {
|
||||
SearchMode::FilesWithMatches
|
||||
| SearchMode::FilesWithoutMatch
|
||||
| SearchMode::Count
|
||||
| SearchMode::Histogram
|
||||
| SearchMode::CountMatches => return false,
|
||||
SearchMode::JSON => return true,
|
||||
SearchMode::Standard => {
|
||||
@ -569,9 +570,10 @@ impl HiArgs {
|
||||
SearchMode::FilesWithoutMatch => SummaryKind::PathWithoutMatch,
|
||||
SearchMode::Count => SummaryKind::Count,
|
||||
SearchMode::CountMatches => SummaryKind::CountMatches,
|
||||
SearchMode::Histogram => SummaryKind::Histogram,
|
||||
SearchMode::JSON => {
|
||||
return Printer::JSON(self.printer_json(wtr))
|
||||
}
|
||||
},
|
||||
SearchMode::Standard => {
|
||||
return Printer::Standard(self.printer_standard(wtr))
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ pub(crate) struct LowArgs {
|
||||
pub(crate) globs: Vec<String>,
|
||||
pub(crate) heading: Option<bool>,
|
||||
pub(crate) hidden: bool,
|
||||
pub(crate) histogram: Option<usize>,
|
||||
pub(crate) histogram: usize,
|
||||
pub(crate) hostname_bin: Option<PathBuf>,
|
||||
pub(crate) hyperlink_format: HyperlinkFormat,
|
||||
pub(crate) iglobs: Vec<String>,
|
||||
@ -210,6 +210,8 @@ pub(crate) enum SearchMode {
|
||||
/// Show files containing at least one match and the total number of
|
||||
/// matches.
|
||||
CountMatches,
|
||||
/// Show a histogram of the matches
|
||||
Histogram,
|
||||
/// Print matches in a JSON lines format.
|
||||
JSON,
|
||||
}
|
||||
|
@ -71,6 +71,8 @@ pub enum SummaryKind {
|
||||
/// If the `path` setting is enabled, then the count is prefixed by the
|
||||
/// corresponding file path.
|
||||
CountMatches,
|
||||
/// Show a histogram of the matches
|
||||
Histogram,
|
||||
/// Show only the file path if and only if a match was found.
|
||||
///
|
||||
/// This ignores the `path` setting and always shows the file path. If no
|
||||
@ -101,7 +103,7 @@ impl SummaryKind {
|
||||
|
||||
match *self {
|
||||
PathWithMatch | PathWithoutMatch => true,
|
||||
Count | CountMatches | Quiet => false,
|
||||
Count | CountMatches | Histogram | Quiet => false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +113,7 @@ impl SummaryKind {
|
||||
use self::SummaryKind::*;
|
||||
|
||||
match *self {
|
||||
CountMatches => true,
|
||||
Histogram |CountMatches => true,
|
||||
Count | PathWithMatch | PathWithoutMatch | Quiet => false,
|
||||
}
|
||||
}
|
||||
@ -123,7 +125,7 @@ impl SummaryKind {
|
||||
|
||||
match *self {
|
||||
PathWithMatch | Quiet => true,
|
||||
Count | CountMatches | PathWithoutMatch => false,
|
||||
Count | CountMatches | Histogram | PathWithoutMatch => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -788,6 +790,9 @@ impl<'p, 's, M: Matcher, W: WriteColor> Sink for SummarySink<'p, 's, M, W> {
|
||||
self.write_line_term(searcher)?;
|
||||
}
|
||||
}
|
||||
SummaryKind::Histogram => {
|
||||
self.write(b"hello")?;
|
||||
},
|
||||
SummaryKind::PathWithMatch => {
|
||||
if self.match_count > 0 {
|
||||
self.write_path_line(searcher)?;
|
||||
|
Reference in New Issue
Block a user