From 10a56695c25c5965f4f2c77a46d1c0e542617da6 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Sat, 25 Dec 2021 00:53:35 +0000 Subject: [PATCH 01/15] Add --header-info option to show more information about file in header Fixes #1701 --- Cargo.lock | 11 ++++ Cargo.toml | 2 + assets/syntaxes/02_Extra/MediaWiki | 2 +- assets/syntaxes/02_Extra/ssh-config | 2 +- src/bin/bat/app.rs | 37 ++++++++++++ src/bin/bat/clap_app.rs | 27 +++++++++ src/config.rs | 4 ++ src/header.rs | 89 +++++++++++++++++++++++++++++ src/input.rs | 32 ++++++++++- src/lib.rs | 1 + src/printer.rs | 89 +++++++++++++++++++++++------ 11 files changed, 274 insertions(+), 22 deletions(-) create mode 100644 src/header.rs diff --git a/Cargo.lock b/Cargo.lock index 4d8fecb172..5bb9244c32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,6 +82,7 @@ dependencies = [ "atty", "bincode", "bugreport", + "bytesize", "clap", "clircle", "console", @@ -105,6 +106,7 @@ dependencies = [ "syntect", "tempfile", "thiserror", + "time", "unicode-width", "wait-timeout", "walkdir", @@ -169,6 +171,15 @@ version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439989e6b8c38d1b6570a384ef1e49c8848128f5a97f3914baef02920842712f" +[[package]] +name = "bytesize" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70" +dependencies = [ + "serde", +] + [[package]] name = "cc" version = "1.0.72" diff --git a/Cargo.toml b/Cargo.toml index 639e9d9656..0e63141e1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,6 +65,8 @@ dirs-next = { version = "2.0.0", optional = true } grep-cli = { version = "0.1.6", optional = true } regex = { version = "1.0", optional = true } walkdir = { version = "2.0", optional = true } +time = { version = "0.3.5", features = ["formatting"] } +bytesize = {version = "1.1.0", features = ["serde"]} [dependencies.git2] version = "0.13" diff --git a/assets/syntaxes/02_Extra/MediaWiki b/assets/syntaxes/02_Extra/MediaWiki index 81bf97cace..843a483e8b 160000 --- a/assets/syntaxes/02_Extra/MediaWiki +++ b/assets/syntaxes/02_Extra/MediaWiki @@ -1 +1 @@ -Subproject commit 81bf97cace59bedcb1668e7830b85c36e014428e +Subproject commit 843a483e8b9f18c4ba914f29a788db5b3a87ed11 diff --git a/assets/syntaxes/02_Extra/ssh-config b/assets/syntaxes/02_Extra/ssh-config index e1012e9f13..201816b609 160000 --- a/assets/syntaxes/02_Extra/ssh-config +++ b/assets/syntaxes/02_Extra/ssh-config @@ -1 +1 @@ -Subproject commit e1012e9f13c6073f559b14206df2ede35720e884 +Subproject commit 201816b609abf7ccf583f7e888f6dc4121410d70 diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 0b17abce0e..b4b99b00dc 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -19,6 +19,7 @@ use bat::{ bat_warning, config::{Config, VisibleLines}, error::*, + header::{HeaderComponent, HeaderComponents}, input::Input, line_range::{HighlightedLineRanges, LineRange, LineRanges}, style::{StyleComponent, StyleComponents}, @@ -78,6 +79,7 @@ impl App { pub fn config(&self, inputs: &[Input]) -> Result { let style_components = self.style_components()?; + let header_components = self.header_components()?; let paging_mode = match self.matches.value_of("paging") { Some("always") => PagingMode::Always, @@ -229,6 +231,7 @@ impl App { ), }, style_components, + header_components, syntax_mapping, pager: self.matches.value_of("pager"), use_italic_text: self.matches.value_of("italic-text") == Some("always"), @@ -338,4 +341,38 @@ impl App { Ok(styled_components) } + + fn header_components(&self) -> Result { + let matches = &self.matches; + let header_components = HeaderComponents({ + let env_header_components: Option> = env::var("BAT_HEADER_INFO") + .ok() + .map(|header_str| { + header_str + .split(',') + .map(HeaderComponent::from_str) + .collect::>>() + }) + .transpose()?; + + matches + .values_of("header-info") + .map(|header| { + header + .map(|header| header.parse::()) + .filter_map(|header| header.ok()) + .collect::>() + }) + .or(env_header_components) + .unwrap_or_else(|| vec![HeaderComponent::Full]) + .into_iter() + .map(|header| header.components()) + .fold(HashSet::new(), |mut acc, components| { + acc.extend(components.iter().cloned()); + acc + }) + }); + + Ok(header_components) + } } diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index e0460f7482..834c6b6237 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -381,6 +381,33 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { .help("Display all supported highlighting themes.") .long_help("Display a list of supported themes for syntax highlighting."), ) + .arg( + Arg::with_name("header-info") + .long("header-info") + .value_name("components") + .use_delimiter(true) + .takes_value(true) + .possible_values(&["full", "auto", "filename", "size", "last-modified", "permissions"]) + .help( + "Comma-separated list of header information elements to display \ + (full, filename, size, last-modified, permissions).", + ) + .long_help( + "Configure what information (filename, file size, last modification date, \ + permissions, ..) to display in the header.\ + The argument is a comma-separated list of \ + components to display (e.g. 'filename,size,last-modified') or all of them ('full'). \ + To set a default set of header information, add the \ + '--header-info=\"..\"' option to the configuration file or export the \ + BAT_HEADER_INFO environment variable (e.g.: export BAT_HEADER_INFO=\"..\").\n\n\ + Possible values:\n\n \ + * full: enables all available components (default).\n \ + * filename: displays the file name.\n \ + * size: displays the size of the file in human-readable format.\n \ + * last-modified: displays the last modification timestamp of the file.\n \ + * permissions: displays the file owner, group and mode.", + ), + ) .arg( Arg::with_name("style") .long("style") diff --git a/src/config.rs b/src/config.rs index 76eb3990cf..a1603f1445 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,3 +1,4 @@ +use crate::header::HeaderComponents; use crate::line_range::{HighlightedLineRanges, LineRanges}; #[cfg(feature = "paging")] use crate::paging::PagingMode; @@ -58,6 +59,9 @@ pub struct Config<'a> { /// Style elements (grid, line numbers, ...) pub style_components: StyleComponents, + /// Header elements (filename, size, ...) + pub header_components: HeaderComponents, + /// If and how text should be wrapped pub wrapping_mode: WrappingMode, diff --git a/src/header.rs b/src/header.rs new file mode 100644 index 0000000000..655d4b9854 --- /dev/null +++ b/src/header.rs @@ -0,0 +1,89 @@ +use std::collections::HashSet; +use std::fmt; +use std::str::FromStr; + +use crate::error::*; + +#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)] +pub enum HeaderComponent { + Filename, + Size, + Permissions, + LastModified, + Full, +} + +impl fmt::Display for HeaderComponent { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // Write strictly the first element into the supplied output + // stream: `f`. Returns `fmt::Result` which indicates whether the + // operation succeeded or failed. Note that `write!` uses syntax which + // is very similar to `println!`. + let name = match self { + HeaderComponent::Filename => "filename", + HeaderComponent::Size => "size", + HeaderComponent::Permissions => "permissions", + HeaderComponent::LastModified => "last-modified", + HeaderComponent::Full => "full", + }; + + write!(f, "{}", name) + } +} + +impl HeaderComponent { + pub fn components(self) -> &'static [HeaderComponent] { + match self { + HeaderComponent::Filename => &[HeaderComponent::Filename], + HeaderComponent::Size => &[HeaderComponent::Size], + HeaderComponent::Permissions => &[HeaderComponent::Permissions], + HeaderComponent::LastModified => &[HeaderComponent::LastModified], + HeaderComponent::Full => &[ + HeaderComponent::Filename, + HeaderComponent::Size, + HeaderComponent::Permissions, + HeaderComponent::LastModified, + ], + } + } +} + +impl FromStr for HeaderComponent { + type Err = Error; + + fn from_str(s: &str) -> Result { + match s { + "filename" => Ok(HeaderComponent::Filename), + "size" => Ok(HeaderComponent::Size), + "permissions" => Ok(HeaderComponent::Permissions), + "last-modified" => Ok(HeaderComponent::LastModified), + "full" => Ok(HeaderComponent::Full), + _ => Err(format!("Unknown header-info '{}'", s).into()), + } + } +} + +#[derive(Debug, Clone, Default)] +pub struct HeaderComponents(pub HashSet); + +impl HeaderComponents { + pub fn new(components: &[HeaderComponent]) -> HeaderComponents { + HeaderComponents(components.iter().cloned().collect()) + } + + pub fn filename(&self) -> bool { + self.0.contains(&HeaderComponent::Filename) + } + + pub fn size(&self) -> bool { + self.0.contains(&HeaderComponent::Size) + } + + pub fn permissions(&self) -> bool { + self.0.contains(&HeaderComponent::Permissions) + } + + pub fn last_modified(&self) -> bool { + self.0.contains(&HeaderComponent::LastModified) + } +} diff --git a/src/input.rs b/src/input.rs index ffaca0ae0b..0aebb9b4c6 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,7 +1,10 @@ use std::convert::TryFrom; +use std::fs; use std::fs::File; use std::io::{self, BufRead, BufReader, Read}; +use std::os::unix::fs::PermissionsExt; use std::path::{Path, PathBuf}; +use std::time::SystemTime; use clircle::{Clircle, Identifier}; use content_inspector::{self, ContentType}; @@ -84,9 +87,17 @@ impl<'a> InputKind<'a> { } } +#[derive(Clone)] +pub(crate) struct InputPermissions { + pub(crate) mode: u32, +} + #[derive(Clone, Default)] pub(crate) struct InputMetadata { pub(crate) user_provided_name: Option, + pub(crate) size: Option, + pub(crate) permissions: Option, + pub(crate) modified: Option, } pub struct Input<'a> { @@ -130,9 +141,28 @@ impl<'a> Input<'a> { fn _ordinary_file(path: &Path) -> Self { let kind = InputKind::OrdinaryFile(path.to_path_buf()); + let metadata = match fs::metadata(path.to_path_buf()) { + Ok(meta) => { + let size = meta.len(); + let modified = meta.modified().ok(); + let perm = meta.permissions(); + InputMetadata { + size: Some(size), + modified: modified, + permissions: Some(InputPermissions { + // the 3 digits from right are the familiar mode bits + // we are looking for + mode: perm.mode() & 0o777, + }), + ..InputMetadata::default() + } + } + Err(_) => InputMetadata::default(), + }; + Input { description: kind.description(), - metadata: InputMetadata::default(), + metadata: metadata, kind, } } diff --git a/src/lib.rs b/src/lib.rs index 37b1cd831f..3016665099 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,6 +32,7 @@ pub mod controller; mod decorations; mod diff; pub mod error; +pub mod header; pub mod input; mod less; pub mod line_range; diff --git a/src/printer.rs b/src/printer.rs index 6b8cbc3a64..7764108b05 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -4,6 +4,9 @@ use std::vec::Vec; use ansi_term::Colour::{Fixed, Green, Red, Yellow}; use ansi_term::Style; +use bytesize::ByteSize; +use time::{format_description, OffsetDateTime}; + use console::AnsiCodeIterator; use syntect::easy::HighlightLines; @@ -26,6 +29,7 @@ use crate::decorations::{Decoration, GridBorderDecoration, LineNumberDecoration} #[cfg(feature = "git")] use crate::diff::LineChanges; use crate::error::*; +use crate::header::HeaderComponent; use crate::input::OpenedInput; use crate::line_range::RangeCheckResult; use crate::preprocessor::{expand_tabs, replace_nonprintable}; @@ -289,15 +293,6 @@ impl<'a> Printer for InteractivePrinter<'a> { if self.config.style_components.grid() { self.print_horizontal_line(handle, '┬')?; - - write!( - handle, - "{}{}", - " ".repeat(self.panel_width), - self.colors - .grid - .paint(if self.panel_width > 0 { "│ " } else { "" }), - )?; } else { // Only pad space between files, if we haven't already drawn a horizontal rule if add_header_padding && !self.config.style_components.rule() { @@ -315,17 +310,73 @@ impl<'a> Printer for InteractivePrinter<'a> { }; let description = &input.description; + let metadata = &input.metadata; + + self.config + .header_components + .0 + .iter() + .try_for_each(|component| { + if self.config.style_components.grid() { + write!( + handle, + "{}{}", + " ".repeat(self.panel_width), + self.colors + .grid + .paint(if self.panel_width > 0 { "│ " } else { "" }), + )?; + }; - writeln!( - handle, - "{}{}{}", - description - .kind() - .map(|kind| format!("{}: ", kind)) - .unwrap_or_else(|| "".into()), - self.colors.filename.paint(description.title()), - mode - )?; + match component { + HeaderComponent::Filename => writeln!( + handle, + "{}{}{}", + description + .kind() + .map(|kind| format!("{}: ", kind)) + .unwrap_or_else(|| "".into()), + self.colors.filename.paint(description.title()), + mode + ), + + HeaderComponent::Size => { + let bsize = metadata + .size + .map(|s| format!("{}", ByteSize(s))) + .unwrap_or("".into()); + writeln!(handle, "Size: {}", bsize) + } + + HeaderComponent::Permissions => writeln!( + handle, + "Permissions: {:o}", + metadata + .permissions + .clone() + .map(|perm| perm.mode) + .unwrap_or(0) + ), + + HeaderComponent::LastModified => { + let format = format_description::parse( + "[day] [month repr:short] [year] [hour]:[minute]:[second]", + ) + .unwrap(); + let fmt_modified = metadata + .modified + .map(|t| OffsetDateTime::from(t).format(&format).unwrap()); + + writeln!( + handle, + "Last Modified At: {}", + fmt_modified.unwrap_or("".into()) + ) + } + + _ => Ok(()), + } + })?; if self.config.style_components.grid() { if self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable { From bf79452f66fc0aa555aad14ecf1d7f3175de73fa Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Wed, 29 Dec 2021 16:27:56 +0000 Subject: [PATCH 02/15] Ordering of results is same as ordering of specified options --- src/bin/bat/app.rs | 2 +- src/header.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index b4b99b00dc..8c7e9e57e4 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -367,7 +367,7 @@ impl App { .unwrap_or_else(|| vec![HeaderComponent::Full]) .into_iter() .map(|header| header.components()) - .fold(HashSet::new(), |mut acc, components| { + .fold(Vec::new(), |mut acc, components| { acc.extend(components.iter().cloned()); acc }) diff --git a/src/header.rs b/src/header.rs index 655d4b9854..61153cecc4 100644 --- a/src/header.rs +++ b/src/header.rs @@ -1,4 +1,3 @@ -use std::collections::HashSet; use std::fmt; use std::str::FromStr; @@ -64,7 +63,7 @@ impl FromStr for HeaderComponent { } #[derive(Debug, Clone, Default)] -pub struct HeaderComponents(pub HashSet); +pub struct HeaderComponents(pub Vec); impl HeaderComponents { pub fn new(components: &[HeaderComponent]) -> HeaderComponents { From 8440f14ebd5948c04a147857e1f6f336cabdf623 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Wed, 29 Dec 2021 20:49:06 +0000 Subject: [PATCH 03/15] Set default to filename --- src/bin/bat/app.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 8c7e9e57e4..e73a494de2 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -364,7 +364,7 @@ impl App { .collect::>() }) .or(env_header_components) - .unwrap_or_else(|| vec![HeaderComponent::Full]) + .unwrap_or_else(|| vec![HeaderComponent::Filename]) .into_iter() .map(|header| header.components()) .fold(Vec::new(), |mut acc, components| { From 25c49cc0defc4ee93745207b090005de4915f96a Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Wed, 29 Dec 2021 21:06:12 +0000 Subject: [PATCH 04/15] Permission modes don't exist on non-unix platforms --- src/input.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/input.rs b/src/input.rs index 0aebb9b4c6..4868ceec7c 100644 --- a/src/input.rs +++ b/src/input.rs @@ -2,6 +2,7 @@ use std::convert::TryFrom; use std::fs; use std::fs::File; use std::io::{self, BufRead, BufReader, Read}; +#[cfg(unix)] use std::os::unix::fs::PermissionsExt; use std::path::{Path, PathBuf}; use std::time::SystemTime; @@ -139,21 +140,32 @@ impl<'a> Input<'a> { Self::_ordinary_file(path.as_ref()) } + #[cfg(unix)] + fn _input_permissions_os(metadata: fs::Metadata) -> Option { + Some(InputPermissions { + // the 3 digits from right are the familiar mode bits + // we are looking for + mode: metadata.permissions().mode() & 0o777, + }) + } + + #[cfg(not(unix))] + fn _input_permissions_os(_metadata: fs::Metadata) -> Option { + None + } + fn _ordinary_file(path: &Path) -> Self { let kind = InputKind::OrdinaryFile(path.to_path_buf()); let metadata = match fs::metadata(path.to_path_buf()) { Ok(meta) => { let size = meta.len(); let modified = meta.modified().ok(); - let perm = meta.permissions(); + let permissions = Self::_input_permissions_os(meta); + InputMetadata { size: Some(size), modified: modified, - permissions: Some(InputPermissions { - // the 3 digits from right are the familiar mode bits - // we are looking for - mode: perm.mode() & 0o777, - }), + permissions: permissions, ..InputMetadata::default() } } From 61ea3d32670d2c11b5ef7798a478d69b41cf557c Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Mon, 3 Jan 2022 07:02:51 +0000 Subject: [PATCH 05/15] Move additional header fields to `--style` --- src/bin/bat/app.rs | 37 ---------- src/bin/bat/clap_app.rs | 39 +++-------- src/config.rs | 4 -- src/header.rs | 88 ------------------------ src/lib.rs | 1 - src/printer.rs | 145 +++++++++++++++++++++++----------------- src/style.rs | 39 +++++++++-- 7 files changed, 128 insertions(+), 225 deletions(-) delete mode 100644 src/header.rs diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index e73a494de2..0b17abce0e 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -19,7 +19,6 @@ use bat::{ bat_warning, config::{Config, VisibleLines}, error::*, - header::{HeaderComponent, HeaderComponents}, input::Input, line_range::{HighlightedLineRanges, LineRange, LineRanges}, style::{StyleComponent, StyleComponents}, @@ -79,7 +78,6 @@ impl App { pub fn config(&self, inputs: &[Input]) -> Result { let style_components = self.style_components()?; - let header_components = self.header_components()?; let paging_mode = match self.matches.value_of("paging") { Some("always") => PagingMode::Always, @@ -231,7 +229,6 @@ impl App { ), }, style_components, - header_components, syntax_mapping, pager: self.matches.value_of("pager"), use_italic_text: self.matches.value_of("italic-text") == Some("always"), @@ -341,38 +338,4 @@ impl App { Ok(styled_components) } - - fn header_components(&self) -> Result { - let matches = &self.matches; - let header_components = HeaderComponents({ - let env_header_components: Option> = env::var("BAT_HEADER_INFO") - .ok() - .map(|header_str| { - header_str - .split(',') - .map(HeaderComponent::from_str) - .collect::>>() - }) - .transpose()?; - - matches - .values_of("header-info") - .map(|header| { - header - .map(|header| header.parse::()) - .filter_map(|header| header.ok()) - .collect::>() - }) - .or(env_header_components) - .unwrap_or_else(|| vec![HeaderComponent::Filename]) - .into_iter() - .map(|header| header.components()) - .fold(Vec::new(), |mut acc, components| { - acc.extend(components.iter().cloned()); - acc - }) - }); - - Ok(header_components) - } } diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 834c6b6237..50766d050e 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -1,3 +1,4 @@ +use bat::bat_warning; use clap::{crate_name, crate_version, App as ClapApp, AppSettings, Arg, ArgGroup, SubCommand}; use once_cell::sync::Lazy; use std::env; @@ -381,33 +382,6 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { .help("Display all supported highlighting themes.") .long_help("Display a list of supported themes for syntax highlighting."), ) - .arg( - Arg::with_name("header-info") - .long("header-info") - .value_name("components") - .use_delimiter(true) - .takes_value(true) - .possible_values(&["full", "auto", "filename", "size", "last-modified", "permissions"]) - .help( - "Comma-separated list of header information elements to display \ - (full, filename, size, last-modified, permissions).", - ) - .long_help( - "Configure what information (filename, file size, last modification date, \ - permissions, ..) to display in the header.\ - The argument is a comma-separated list of \ - components to display (e.g. 'filename,size,last-modified') or all of them ('full'). \ - To set a default set of header information, add the \ - '--header-info=\"..\"' option to the configuration file or export the \ - BAT_HEADER_INFO environment variable (e.g.: export BAT_HEADER_INFO=\"..\").\n\n\ - Possible values:\n\n \ - * full: enables all available components (default).\n \ - * filename: displays the file name.\n \ - * size: displays the size of the file in human-readable format.\n \ - * last-modified: displays the last modification timestamp of the file.\n \ - * permissions: displays the file owner, group and mode.", - ), - ) .arg( Arg::with_name("style") .long("style") @@ -423,13 +397,17 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { .validator(|val| { let mut invalid_vals = val.split(',').filter(|style| { !&[ - "auto", "full", "plain", "header", "grid", "rule", "numbers", "snip", + "auto", "full", "plain", "header", "filename", "filesize", "permissions", "lastmodified", "grid", "rule", "numbers", "snip", #[cfg(feature = "git")] "changes", ] .contains(style) }); + if val.contains("header") { + bat_warning!("Style 'header' is deprecated, use 'filename' instead."); + } + if let Some(invalid) = invalid_vals.next() { Err(format!("Unknown style, '{}'", invalid)) } else { @@ -453,7 +431,10 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { * auto: same as 'full', unless the output is piped.\n \ * plain: disables all available components.\n \ * changes: show Git modification markers.\n \ - * header: show filenames before the content.\n \ + * filename: displays the file name.\n \ + * size: displays the size of the file in human-readable format.\n \ + * last-modified: displays the last modification timestamp of the file.\n \ + * permissions: displays the file owner, group and mode.\n \ * grid: vertical/horizontal lines to separate side bar\n \ and the header from the content.\n \ * rule: horizontal lines to delimit files.\n \ diff --git a/src/config.rs b/src/config.rs index a1603f1445..76eb3990cf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,3 @@ -use crate::header::HeaderComponents; use crate::line_range::{HighlightedLineRanges, LineRanges}; #[cfg(feature = "paging")] use crate::paging::PagingMode; @@ -59,9 +58,6 @@ pub struct Config<'a> { /// Style elements (grid, line numbers, ...) pub style_components: StyleComponents, - /// Header elements (filename, size, ...) - pub header_components: HeaderComponents, - /// If and how text should be wrapped pub wrapping_mode: WrappingMode, diff --git a/src/header.rs b/src/header.rs deleted file mode 100644 index 61153cecc4..0000000000 --- a/src/header.rs +++ /dev/null @@ -1,88 +0,0 @@ -use std::fmt; -use std::str::FromStr; - -use crate::error::*; - -#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)] -pub enum HeaderComponent { - Filename, - Size, - Permissions, - LastModified, - Full, -} - -impl fmt::Display for HeaderComponent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // Write strictly the first element into the supplied output - // stream: `f`. Returns `fmt::Result` which indicates whether the - // operation succeeded or failed. Note that `write!` uses syntax which - // is very similar to `println!`. - let name = match self { - HeaderComponent::Filename => "filename", - HeaderComponent::Size => "size", - HeaderComponent::Permissions => "permissions", - HeaderComponent::LastModified => "last-modified", - HeaderComponent::Full => "full", - }; - - write!(f, "{}", name) - } -} - -impl HeaderComponent { - pub fn components(self) -> &'static [HeaderComponent] { - match self { - HeaderComponent::Filename => &[HeaderComponent::Filename], - HeaderComponent::Size => &[HeaderComponent::Size], - HeaderComponent::Permissions => &[HeaderComponent::Permissions], - HeaderComponent::LastModified => &[HeaderComponent::LastModified], - HeaderComponent::Full => &[ - HeaderComponent::Filename, - HeaderComponent::Size, - HeaderComponent::Permissions, - HeaderComponent::LastModified, - ], - } - } -} - -impl FromStr for HeaderComponent { - type Err = Error; - - fn from_str(s: &str) -> Result { - match s { - "filename" => Ok(HeaderComponent::Filename), - "size" => Ok(HeaderComponent::Size), - "permissions" => Ok(HeaderComponent::Permissions), - "last-modified" => Ok(HeaderComponent::LastModified), - "full" => Ok(HeaderComponent::Full), - _ => Err(format!("Unknown header-info '{}'", s).into()), - } - } -} - -#[derive(Debug, Clone, Default)] -pub struct HeaderComponents(pub Vec); - -impl HeaderComponents { - pub fn new(components: &[HeaderComponent]) -> HeaderComponents { - HeaderComponents(components.iter().cloned().collect()) - } - - pub fn filename(&self) -> bool { - self.0.contains(&HeaderComponent::Filename) - } - - pub fn size(&self) -> bool { - self.0.contains(&HeaderComponent::Size) - } - - pub fn permissions(&self) -> bool { - self.0.contains(&HeaderComponent::Permissions) - } - - pub fn last_modified(&self) -> bool { - self.0.contains(&HeaderComponent::LastModified) - } -} diff --git a/src/lib.rs b/src/lib.rs index 3016665099..37b1cd831f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,6 @@ pub mod controller; mod decorations; mod diff; pub mod error; -pub mod header; pub mod input; mod less; pub mod line_range; diff --git a/src/printer.rs b/src/printer.rs index 7764108b05..d5f860365f 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -29,10 +29,10 @@ use crate::decorations::{Decoration, GridBorderDecoration, LineNumberDecoration} #[cfg(feature = "git")] use crate::diff::LineChanges; use crate::error::*; -use crate::header::HeaderComponent; use crate::input::OpenedInput; use crate::line_range::RangeCheckResult; use crate::preprocessor::{expand_tabs, replace_nonprintable}; +use crate::style::StyleComponent; use crate::terminal::{as_terminal_escaped, to_ansi_color}; use crate::vscreen::AnsiStyle; use crate::wrapping::WrappingMode; @@ -312,71 +312,92 @@ impl<'a> Printer for InteractivePrinter<'a> { let description = &input.description; let metadata = &input.metadata; - self.config - .header_components - .0 - .iter() - .try_for_each(|component| { - if self.config.style_components.grid() { - write!( - handle, - "{}{}", - " ".repeat(self.panel_width), - self.colors - .grid - .paint(if self.panel_width > 0 { "│ " } else { "" }), - )?; - }; + // We use this iterator to have a deterministic order for + // header components. HashSet has arbitrary order, but Vec is ordered. + let header_components: Vec = [ + ( + StyleComponent::Filename, + self.config.style_components.filename(), + ), + ( + StyleComponent::Filesize, + self.config.style_components.filesize(), + ), + ( + StyleComponent::Permissions, + self.config.style_components.permissions(), + ), + ( + StyleComponent::LastModified, + self.config.style_components.last_modified(), + ), + ] + .iter() + .filter(|(_, is_enabled)| *is_enabled) + .map(|(component, _)| *component) + .collect(); + + header_components.iter().try_for_each(|component| { + if self.config.style_components.grid() { + write!( + handle, + "{}{}", + " ".repeat(self.panel_width), + self.colors + .grid + .paint(if self.panel_width > 0 { "│ " } else { "" }), + )?; + }; - match component { - HeaderComponent::Filename => writeln!( - handle, - "{}{}{}", - description - .kind() - .map(|kind| format!("{}: ", kind)) - .unwrap_or_else(|| "".into()), - self.colors.filename.paint(description.title()), - mode - ), - - HeaderComponent::Size => { - let bsize = metadata - .size - .map(|s| format!("{}", ByteSize(s))) - .unwrap_or("".into()); - writeln!(handle, "Size: {}", bsize) - } + match component { + StyleComponent::Filename => writeln!( + handle, + "{}{}{}", + description + .kind() + .map(|kind| format!("{}: ", kind)) + .unwrap_or_else(|| "".into()), + self.colors.filename.paint(description.title()), + mode + ), + + StyleComponent::Filesize => { + let bsize = metadata + .size + .map(|s| format!("{}", ByteSize(s))) + .unwrap_or("".into()); + writeln!(handle, "Size: {}", bsize) + } - HeaderComponent::Permissions => writeln!( + StyleComponent::Permissions => writeln!( + handle, + "Permissions: {:o}", + metadata + .permissions + .clone() + .map(|perm| perm.mode) + .unwrap_or(0) + ), + + StyleComponent::LastModified => { + let format = format_description::parse( + "[day] [month repr:short] [year] [hour]:[minute]:[second]", + ) + .unwrap(); + let fmt_modified = metadata + .modified + .map(|t| OffsetDateTime::from(t).format(&format).unwrap()); + + writeln!( handle, - "Permissions: {:o}", - metadata - .permissions - .clone() - .map(|perm| perm.mode) - .unwrap_or(0) - ), - - HeaderComponent::LastModified => { - let format = format_description::parse( - "[day] [month repr:short] [year] [hour]:[minute]:[second]", - ) - .unwrap(); - let fmt_modified = metadata - .modified - .map(|t| OffsetDateTime::from(t).format(&format).unwrap()); - - writeln!( - handle, - "Last Modified At: {}", - fmt_modified.unwrap_or("".into()) - ) - } - - _ => Ok(()), + "Last Modified At: {}", + fmt_modified.unwrap_or("".into()) + ) } - })?; + + _ => Ok(()), + } + })?; if self.config.style_components.grid() { if self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable { diff --git a/src/style.rs b/src/style.rs index 654142068b..b2871d06f4 100644 --- a/src/style.rs +++ b/src/style.rs @@ -11,6 +11,10 @@ pub enum StyleComponent { Grid, Rule, Header, + Filename, + Filesize, + Permissions, + LastModified, LineNumbers, Snip, Full, @@ -31,14 +35,21 @@ impl StyleComponent { StyleComponent::Changes => &[StyleComponent::Changes], StyleComponent::Grid => &[StyleComponent::Grid], StyleComponent::Rule => &[StyleComponent::Rule], - StyleComponent::Header => &[StyleComponent::Header], + StyleComponent::Header => &[StyleComponent::Filename], + StyleComponent::Filename => &[StyleComponent::Filename], + StyleComponent::Filesize => &[StyleComponent::Filesize], + StyleComponent::Permissions => &[StyleComponent::Permissions], + StyleComponent::LastModified => &[StyleComponent::LastModified], StyleComponent::LineNumbers => &[StyleComponent::LineNumbers], StyleComponent::Snip => &[StyleComponent::Snip], StyleComponent::Full => &[ #[cfg(feature = "git")] StyleComponent::Changes, StyleComponent::Grid, - StyleComponent::Header, + StyleComponent::Filename, + StyleComponent::Filesize, + StyleComponent::Permissions, + StyleComponent::LastModified, StyleComponent::LineNumbers, StyleComponent::Snip, ], @@ -57,7 +68,11 @@ impl FromStr for StyleComponent { "changes" => Ok(StyleComponent::Changes), "grid" => Ok(StyleComponent::Grid), "rule" => Ok(StyleComponent::Rule), - "header" => Ok(StyleComponent::Header), + "header" => Ok(StyleComponent::Filename), + "filename" => Ok(StyleComponent::Filename), + "filesize" => Ok(StyleComponent::Filesize), + "permissions" => Ok(StyleComponent::Permissions), + "lastmodified" => Ok(StyleComponent::LastModified), "numbers" => Ok(StyleComponent::LineNumbers), "snip" => Ok(StyleComponent::Snip), "full" => Ok(StyleComponent::Full), @@ -89,7 +104,23 @@ impl StyleComponents { } pub fn header(&self) -> bool { - self.0.contains(&StyleComponent::Header) + self.filename() || self.filesize() || self.permissions() || self.last_modified() + } + + pub fn filename(&self) -> bool { + self.0.contains(&StyleComponent::Filename) + } + + pub fn filesize(&self) -> bool { + self.0.contains(&StyleComponent::Filesize) + } + + pub fn permissions(&self) -> bool { + self.0.contains(&StyleComponent::Permissions) + } + + pub fn last_modified(&self) -> bool { + self.0.contains(&StyleComponent::LastModified) } pub fn numbers(&self) -> bool { From 8bbf6b05af609719127263ece3c9b1bde66a4ce8 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Tue, 4 Jan 2022 08:48:26 +0000 Subject: [PATCH 06/15] Prefix header styles with `header-` and add `header-full` --- src/bin/bat/clap_app.rs | 17 +++++------ src/input.rs | 6 ++-- src/printer.rs | 24 +++++++-------- src/style.rs | 68 +++++++++++++++++++++++++---------------- 4 files changed, 63 insertions(+), 52 deletions(-) diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 50766d050e..003bd51d04 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -1,4 +1,3 @@ -use bat::bat_warning; use clap::{crate_name, crate_version, App as ClapApp, AppSettings, Arg, ArgGroup, SubCommand}; use once_cell::sync::Lazy; use std::env; @@ -397,17 +396,13 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { .validator(|val| { let mut invalid_vals = val.split(',').filter(|style| { !&[ - "auto", "full", "plain", "header", "filename", "filesize", "permissions", "lastmodified", "grid", "rule", "numbers", "snip", + "auto", "full", "plain", "header", "header-full", "header-filename", "header-filesize", "header-permissions", "header-lastmodified", "grid", "rule", "numbers", "snip", #[cfg(feature = "git")] "changes", ] .contains(style) }); - if val.contains("header") { - bat_warning!("Style 'header' is deprecated, use 'filename' instead."); - } - if let Some(invalid) = invalid_vals.next() { Err(format!("Unknown style, '{}'", invalid)) } else { @@ -431,10 +426,12 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { * auto: same as 'full', unless the output is piped.\n \ * plain: disables all available components.\n \ * changes: show Git modification markers.\n \ - * filename: displays the file name.\n \ - * size: displays the size of the file in human-readable format.\n \ - * last-modified: displays the last modification timestamp of the file.\n \ - * permissions: displays the file owner, group and mode.\n \ + * header: displays the filename and filesize.\n \ + * header-full: displays all header-* fields.\n \ + * header-filename: displays the file name.\n \ + * header-filesize: displays the size of the file in human-readable format.\n \ + * header-last-modified: displays the last modification timestamp of the file.\n \ + * header-permissions: displays the file owner, group and mode.\n \ * grid: vertical/horizontal lines to separate side bar\n \ and the header from the content.\n \ * rule: horizontal lines to delimit files.\n \ diff --git a/src/input.rs b/src/input.rs index 4868ceec7c..fc2e1e5646 100644 --- a/src/input.rs +++ b/src/input.rs @@ -164,8 +164,8 @@ impl<'a> Input<'a> { InputMetadata { size: Some(size), - modified: modified, - permissions: permissions, + modified, + permissions, ..InputMetadata::default() } } @@ -174,7 +174,7 @@ impl<'a> Input<'a> { Input { description: kind.description(), - metadata: metadata, + metadata, kind, } } diff --git a/src/printer.rs b/src/printer.rs index d5f860365f..a289147e3d 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -316,20 +316,20 @@ impl<'a> Printer for InteractivePrinter<'a> { // header components. HashSet has arbitrary order, but Vec is ordered. let header_components: Vec = [ ( - StyleComponent::Filename, - self.config.style_components.filename(), + StyleComponent::HeaderFilename, + self.config.style_components.header_filename(), ), ( - StyleComponent::Filesize, - self.config.style_components.filesize(), + StyleComponent::HeaderFilesize, + self.config.style_components.header_filesize(), ), ( - StyleComponent::Permissions, - self.config.style_components.permissions(), + StyleComponent::HeaderPermissions, + self.config.style_components.header_permissions(), ), ( - StyleComponent::LastModified, - self.config.style_components.last_modified(), + StyleComponent::HeaderLastModified, + self.config.style_components.header_last_modified(), ), ] .iter() @@ -350,7 +350,7 @@ impl<'a> Printer for InteractivePrinter<'a> { }; match component { - StyleComponent::Filename => writeln!( + StyleComponent::HeaderFilename => writeln!( handle, "{}{}{}", description @@ -361,7 +361,7 @@ impl<'a> Printer for InteractivePrinter<'a> { mode ), - StyleComponent::Filesize => { + StyleComponent::HeaderFilesize => { let bsize = metadata .size .map(|s| format!("{}", ByteSize(s))) @@ -369,7 +369,7 @@ impl<'a> Printer for InteractivePrinter<'a> { writeln!(handle, "Size: {}", bsize) } - StyleComponent::Permissions => writeln!( + StyleComponent::HeaderPermissions => writeln!( handle, "Permissions: {:o}", metadata @@ -379,7 +379,7 @@ impl<'a> Printer for InteractivePrinter<'a> { .unwrap_or(0) ), - StyleComponent::LastModified => { + StyleComponent::HeaderLastModified => { let format = format_description::parse( "[day] [month repr:short] [year] [hour]:[minute]:[second]", ) diff --git a/src/style.rs b/src/style.rs index b2871d06f4..ef962bd213 100644 --- a/src/style.rs +++ b/src/style.rs @@ -11,10 +11,11 @@ pub enum StyleComponent { Grid, Rule, Header, - Filename, - Filesize, - Permissions, - LastModified, + HeaderFull, + HeaderFilename, + HeaderFilesize, + HeaderPermissions, + HeaderLastModified, LineNumbers, Snip, Full, @@ -35,21 +36,30 @@ impl StyleComponent { StyleComponent::Changes => &[StyleComponent::Changes], StyleComponent::Grid => &[StyleComponent::Grid], StyleComponent::Rule => &[StyleComponent::Rule], - StyleComponent::Header => &[StyleComponent::Filename], - StyleComponent::Filename => &[StyleComponent::Filename], - StyleComponent::Filesize => &[StyleComponent::Filesize], - StyleComponent::Permissions => &[StyleComponent::Permissions], - StyleComponent::LastModified => &[StyleComponent::LastModified], + StyleComponent::Header => &[ + StyleComponent::HeaderFilename, + StyleComponent::HeaderFilesize, + ], + StyleComponent::HeaderFull => &[ + StyleComponent::HeaderFilename, + StyleComponent::HeaderFilesize, + StyleComponent::HeaderPermissions, + StyleComponent::HeaderLastModified, + ], + StyleComponent::HeaderFilename => &[StyleComponent::HeaderFilename], + StyleComponent::HeaderFilesize => &[StyleComponent::HeaderFilesize], + StyleComponent::HeaderPermissions => &[StyleComponent::HeaderPermissions], + StyleComponent::HeaderLastModified => &[StyleComponent::HeaderLastModified], StyleComponent::LineNumbers => &[StyleComponent::LineNumbers], StyleComponent::Snip => &[StyleComponent::Snip], StyleComponent::Full => &[ #[cfg(feature = "git")] StyleComponent::Changes, StyleComponent::Grid, - StyleComponent::Filename, - StyleComponent::Filesize, - StyleComponent::Permissions, - StyleComponent::LastModified, + StyleComponent::HeaderFilename, + StyleComponent::HeaderFilesize, + StyleComponent::HeaderPermissions, + StyleComponent::HeaderLastModified, StyleComponent::LineNumbers, StyleComponent::Snip, ], @@ -68,11 +78,12 @@ impl FromStr for StyleComponent { "changes" => Ok(StyleComponent::Changes), "grid" => Ok(StyleComponent::Grid), "rule" => Ok(StyleComponent::Rule), - "header" => Ok(StyleComponent::Filename), - "filename" => Ok(StyleComponent::Filename), - "filesize" => Ok(StyleComponent::Filesize), - "permissions" => Ok(StyleComponent::Permissions), - "lastmodified" => Ok(StyleComponent::LastModified), + "header" => Ok(StyleComponent::Header), + "header-full" => Ok(StyleComponent::HeaderFull), + "header-filename" => Ok(StyleComponent::HeaderFilename), + "header-filesize" => Ok(StyleComponent::HeaderFilesize), + "header-permissions" => Ok(StyleComponent::HeaderPermissions), + "header-lastmodified" => Ok(StyleComponent::HeaderLastModified), "numbers" => Ok(StyleComponent::LineNumbers), "snip" => Ok(StyleComponent::Snip), "full" => Ok(StyleComponent::Full), @@ -104,23 +115,26 @@ impl StyleComponents { } pub fn header(&self) -> bool { - self.filename() || self.filesize() || self.permissions() || self.last_modified() + self.header_filename() + || self.header_filesize() + || self.header_permissions() + || self.header_last_modified() } - pub fn filename(&self) -> bool { - self.0.contains(&StyleComponent::Filename) + pub fn header_filename(&self) -> bool { + self.0.contains(&StyleComponent::HeaderFilename) } - pub fn filesize(&self) -> bool { - self.0.contains(&StyleComponent::Filesize) + pub fn header_filesize(&self) -> bool { + self.0.contains(&StyleComponent::HeaderFilesize) } - pub fn permissions(&self) -> bool { - self.0.contains(&StyleComponent::Permissions) + pub fn header_permissions(&self) -> bool { + self.0.contains(&StyleComponent::HeaderPermissions) } - pub fn last_modified(&self) -> bool { - self.0.contains(&StyleComponent::LastModified) + pub fn header_last_modified(&self) -> bool { + self.0.contains(&StyleComponent::HeaderLastModified) } pub fn numbers(&self) -> bool { From 6ef351ab6d8ab6859f11ead53a76fb8a73885540 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Sun, 9 Jan 2022 21:28:10 +0000 Subject: [PATCH 07/15] header values in bold, auto = all with 'header' --- src/bin/bat/app.rs | 2 +- src/bin/bat/clap_app.rs | 24 ++++++++++++++++++------ src/printer.rs | 38 +++++++++++++++++++++++--------------- src/style.rs | 10 +++++++++- 4 files changed, 51 insertions(+), 23 deletions(-) diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 0b17abce0e..477bb0ff0e 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -322,7 +322,7 @@ impl App { .collect::>() }) .or(env_style_components) - .unwrap_or_else(|| vec![StyleComponent::Full]) + .unwrap_or_else(|| vec![StyleComponent::Auto]) .into_iter() .map(|style| style.components(self.interactive_output)) .fold(HashSet::new(), |mut acc, components| { diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 003bd51d04..61732354a6 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -396,11 +396,22 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { .validator(|val| { let mut invalid_vals = val.split(',').filter(|style| { !&[ - "auto", "full", "plain", "header", "header-full", "header-filename", "header-filesize", "header-permissions", "header-lastmodified", "grid", "rule", "numbers", "snip", + "auto", + "full", + "plain", + "header", + "header-full", + "header-filename", + "header-filesize", + "header-permissions", + "header-lastmodified", + "grid", + "rule", + "numbers", + "snip", #[cfg(feature = "git")] - "changes", - ] - .contains(style) + "changes", + ].contains(style) }); if let Some(invalid) = invalid_vals.next() { @@ -422,8 +433,9 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { '--style=\"..\"' option to the configuration file or export the \ BAT_STYLE environment variable (e.g.: export BAT_STYLE=\"..\").\n\n\ Possible values:\n\n \ - * full: enables all available components (default).\n \ - * auto: same as 'full', unless the output is piped.\n \ + * auto: enables all components and 'header', unless the output is piped. + * (default)\n \ + * full: enables all available components.\n \ * plain: disables all available components.\n \ * changes: show Git modification markers.\n \ * header: displays the filename and filesize.\n \ diff --git a/src/printer.rs b/src/printer.rs index a289147e3d..623cc57a5d 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -357,7 +357,7 @@ impl<'a> Printer for InteractivePrinter<'a> { .kind() .map(|kind| format!("{}: ", kind)) .unwrap_or_else(|| "".into()), - self.colors.filename.paint(description.title()), + self.colors.header_value.paint(description.title()), mode ), @@ -366,18 +366,24 @@ impl<'a> Printer for InteractivePrinter<'a> { .size .map(|s| format!("{}", ByteSize(s))) .unwrap_or("".into()); - writeln!(handle, "Size: {}", bsize) + writeln!(handle, "Size: {}", self.colors.header_value.paint(bsize)) } - StyleComponent::HeaderPermissions => writeln!( - handle, - "Permissions: {:o}", - metadata - .permissions - .clone() - .map(|perm| perm.mode) - .unwrap_or(0) - ), + StyleComponent::HeaderPermissions => { + let fmt_perms = format!( + "{:o}", + metadata + .permissions + .clone() + .map(|perm| perm.mode) + .unwrap_or(0) + ); + writeln!( + handle, + "Permissions: {}", + self.colors.header_value.paint(fmt_perms) + ) + } StyleComponent::HeaderLastModified => { let format = format_description::parse( @@ -390,8 +396,10 @@ impl<'a> Printer for InteractivePrinter<'a> { writeln!( handle, - "Last Modified At: {}", - fmt_modified.unwrap_or("".into()) + "Modified: {}", + self.colors + .header_value + .paint(fmt_modified.unwrap_or("".into())) ) } @@ -689,7 +697,7 @@ const DEFAULT_GUTTER_COLOR: u8 = 238; pub struct Colors { pub grid: Style, pub rule: Style, - pub filename: Style, + pub header_value: Style, pub git_added: Style, pub git_removed: Style, pub git_modified: Style, @@ -718,7 +726,7 @@ impl Colors { Colors { grid: gutter_style, rule: gutter_style, - filename: Style::new().bold(), + header_value: Style::new().bold(), git_added: Green.normal(), git_removed: Red.normal(), git_modified: Yellow.normal(), diff --git a/src/style.rs b/src/style.rs index ef962bd213..f4901f1b53 100644 --- a/src/style.rs +++ b/src/style.rs @@ -27,7 +27,15 @@ impl StyleComponent { match self { StyleComponent::Auto => { if interactive_terminal { - StyleComponent::Full.components(interactive_terminal) + &[ + #[cfg(feature = "git")] + StyleComponent::Changes, + StyleComponent::Grid, + StyleComponent::HeaderFilename, + StyleComponent::HeaderFilesize, + StyleComponent::LineNumbers, + StyleComponent::Snip, + ] } else { StyleComponent::Plain.components(interactive_terminal) } From 412f6a258f4a2eb84b87abfabb0b7ebb9dd3df06 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Mon, 17 Jan 2022 20:00:05 +0000 Subject: [PATCH 08/15] refactor: remove last-modified and permissions, simplify header --- Cargo.lock | 1 - Cargo.toml | 1 - src/bin/bat/app.rs | 2 +- src/bin/bat/clap_app.rs | 13 ++----- src/input.rs | 28 -------------- src/printer.rs | 49 ++---------------------- src/style.rs | 44 ++------------------- tests/integration_tests.rs | 29 +++++++------- tests/snapshots/output/full.snapshot.txt | 1 + 9 files changed, 27 insertions(+), 141 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5bb9244c32..961b2d378f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,7 +106,6 @@ dependencies = [ "syntect", "tempfile", "thiserror", - "time", "unicode-width", "wait-timeout", "walkdir", diff --git a/Cargo.toml b/Cargo.toml index 0e63141e1c..73bfe7214a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,6 @@ dirs-next = { version = "2.0.0", optional = true } grep-cli = { version = "0.1.6", optional = true } regex = { version = "1.0", optional = true } walkdir = { version = "2.0", optional = true } -time = { version = "0.3.5", features = ["formatting"] } bytesize = {version = "1.1.0", features = ["serde"]} [dependencies.git2] diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 477bb0ff0e..0b17abce0e 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -322,7 +322,7 @@ impl App { .collect::>() }) .or(env_style_components) - .unwrap_or_else(|| vec![StyleComponent::Auto]) + .unwrap_or_else(|| vec![StyleComponent::Full]) .into_iter() .map(|style| style.components(self.interactive_output)) .fold(HashSet::new(), |mut acc, components| { diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 61732354a6..cc34f18c2c 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -400,11 +400,8 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { "full", "plain", "header", - "header-full", "header-filename", "header-filesize", - "header-permissions", - "header-lastmodified", "grid", "rule", "numbers", @@ -433,17 +430,13 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { '--style=\"..\"' option to the configuration file or export the \ BAT_STYLE environment variable (e.g.: export BAT_STYLE=\"..\").\n\n\ Possible values:\n\n \ - * auto: enables all components and 'header', unless the output is piped. - * (default)\n \ - * full: enables all available components.\n \ + * full: enables all available components (default).\n \ + * auto: same as 'full', unless the output is piped.\n \ * plain: disables all available components.\n \ * changes: show Git modification markers.\n \ - * header: displays the filename and filesize.\n \ - * header-full: displays all header-* fields.\n \ + * header: show filenames before the content.\n \ * header-filename: displays the file name.\n \ * header-filesize: displays the size of the file in human-readable format.\n \ - * header-last-modified: displays the last modification timestamp of the file.\n \ - * header-permissions: displays the file owner, group and mode.\n \ * grid: vertical/horizontal lines to separate side bar\n \ and the header from the content.\n \ * rule: horizontal lines to delimit files.\n \ diff --git a/src/input.rs b/src/input.rs index fc2e1e5646..f55c0ac62a 100644 --- a/src/input.rs +++ b/src/input.rs @@ -2,10 +2,7 @@ use std::convert::TryFrom; use std::fs; use std::fs::File; use std::io::{self, BufRead, BufReader, Read}; -#[cfg(unix)] -use std::os::unix::fs::PermissionsExt; use std::path::{Path, PathBuf}; -use std::time::SystemTime; use clircle::{Clircle, Identifier}; use content_inspector::{self, ContentType}; @@ -88,17 +85,10 @@ impl<'a> InputKind<'a> { } } -#[derive(Clone)] -pub(crate) struct InputPermissions { - pub(crate) mode: u32, -} - #[derive(Clone, Default)] pub(crate) struct InputMetadata { pub(crate) user_provided_name: Option, pub(crate) size: Option, - pub(crate) permissions: Option, - pub(crate) modified: Option, } pub struct Input<'a> { @@ -140,32 +130,14 @@ impl<'a> Input<'a> { Self::_ordinary_file(path.as_ref()) } - #[cfg(unix)] - fn _input_permissions_os(metadata: fs::Metadata) -> Option { - Some(InputPermissions { - // the 3 digits from right are the familiar mode bits - // we are looking for - mode: metadata.permissions().mode() & 0o777, - }) - } - - #[cfg(not(unix))] - fn _input_permissions_os(_metadata: fs::Metadata) -> Option { - None - } - fn _ordinary_file(path: &Path) -> Self { let kind = InputKind::OrdinaryFile(path.to_path_buf()); let metadata = match fs::metadata(path.to_path_buf()) { Ok(meta) => { let size = meta.len(); - let modified = meta.modified().ok(); - let permissions = Self::_input_permissions_os(meta); InputMetadata { size: Some(size), - modified, - permissions, ..InputMetadata::default() } } diff --git a/src/printer.rs b/src/printer.rs index 623cc57a5d..d0c49d3bf5 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -5,7 +5,6 @@ use ansi_term::Colour::{Fixed, Green, Red, Yellow}; use ansi_term::Style; use bytesize::ByteSize; -use time::{format_description, OffsetDateTime}; use console::AnsiCodeIterator; @@ -298,7 +297,6 @@ impl<'a> Printer for InteractivePrinter<'a> { if add_header_padding && !self.config.style_components.rule() { writeln!(handle)?; } - write!(handle, "{}", " ".repeat(self.panel_width))?; } let mode = match self.content_type { @@ -323,14 +321,6 @@ impl<'a> Printer for InteractivePrinter<'a> { StyleComponent::HeaderFilesize, self.config.style_components.header_filesize(), ), - ( - StyleComponent::HeaderPermissions, - self.config.style_components.header_permissions(), - ), - ( - StyleComponent::HeaderLastModified, - self.config.style_components.header_last_modified(), - ), ] .iter() .filter(|(_, is_enabled)| *is_enabled) @@ -347,7 +337,9 @@ impl<'a> Printer for InteractivePrinter<'a> { .grid .paint(if self.panel_width > 0 { "│ " } else { "" }), )?; - }; + } else { + write!(handle, "{}", " ".repeat(self.panel_width))?; + } match component { StyleComponent::HeaderFilename => writeln!( @@ -368,41 +360,6 @@ impl<'a> Printer for InteractivePrinter<'a> { .unwrap_or("".into()); writeln!(handle, "Size: {}", self.colors.header_value.paint(bsize)) } - - StyleComponent::HeaderPermissions => { - let fmt_perms = format!( - "{:o}", - metadata - .permissions - .clone() - .map(|perm| perm.mode) - .unwrap_or(0) - ); - writeln!( - handle, - "Permissions: {}", - self.colors.header_value.paint(fmt_perms) - ) - } - - StyleComponent::HeaderLastModified => { - let format = format_description::parse( - "[day] [month repr:short] [year] [hour]:[minute]:[second]", - ) - .unwrap(); - let fmt_modified = metadata - .modified - .map(|t| OffsetDateTime::from(t).format(&format).unwrap()); - - writeln!( - handle, - "Modified: {}", - self.colors - .header_value - .paint(fmt_modified.unwrap_or("".into())) - ) - } - _ => Ok(()), } })?; diff --git a/src/style.rs b/src/style.rs index f4901f1b53..52816e8237 100644 --- a/src/style.rs +++ b/src/style.rs @@ -11,11 +11,8 @@ pub enum StyleComponent { Grid, Rule, Header, - HeaderFull, HeaderFilename, HeaderFilesize, - HeaderPermissions, - HeaderLastModified, LineNumbers, Snip, Full, @@ -27,15 +24,7 @@ impl StyleComponent { match self { StyleComponent::Auto => { if interactive_terminal { - &[ - #[cfg(feature = "git")] - StyleComponent::Changes, - StyleComponent::Grid, - StyleComponent::HeaderFilename, - StyleComponent::HeaderFilesize, - StyleComponent::LineNumbers, - StyleComponent::Snip, - ] + StyleComponent::Full.components(interactive_terminal) } else { StyleComponent::Plain.components(interactive_terminal) } @@ -44,20 +33,9 @@ impl StyleComponent { StyleComponent::Changes => &[StyleComponent::Changes], StyleComponent::Grid => &[StyleComponent::Grid], StyleComponent::Rule => &[StyleComponent::Rule], - StyleComponent::Header => &[ - StyleComponent::HeaderFilename, - StyleComponent::HeaderFilesize, - ], - StyleComponent::HeaderFull => &[ - StyleComponent::HeaderFilename, - StyleComponent::HeaderFilesize, - StyleComponent::HeaderPermissions, - StyleComponent::HeaderLastModified, - ], + StyleComponent::Header => &[StyleComponent::HeaderFilename], StyleComponent::HeaderFilename => &[StyleComponent::HeaderFilename], StyleComponent::HeaderFilesize => &[StyleComponent::HeaderFilesize], - StyleComponent::HeaderPermissions => &[StyleComponent::HeaderPermissions], - StyleComponent::HeaderLastModified => &[StyleComponent::HeaderLastModified], StyleComponent::LineNumbers => &[StyleComponent::LineNumbers], StyleComponent::Snip => &[StyleComponent::Snip], StyleComponent::Full => &[ @@ -66,8 +44,6 @@ impl StyleComponent { StyleComponent::Grid, StyleComponent::HeaderFilename, StyleComponent::HeaderFilesize, - StyleComponent::HeaderPermissions, - StyleComponent::HeaderLastModified, StyleComponent::LineNumbers, StyleComponent::Snip, ], @@ -87,11 +63,8 @@ impl FromStr for StyleComponent { "grid" => Ok(StyleComponent::Grid), "rule" => Ok(StyleComponent::Rule), "header" => Ok(StyleComponent::Header), - "header-full" => Ok(StyleComponent::HeaderFull), "header-filename" => Ok(StyleComponent::HeaderFilename), "header-filesize" => Ok(StyleComponent::HeaderFilesize), - "header-permissions" => Ok(StyleComponent::HeaderPermissions), - "header-lastmodified" => Ok(StyleComponent::HeaderLastModified), "numbers" => Ok(StyleComponent::LineNumbers), "snip" => Ok(StyleComponent::Snip), "full" => Ok(StyleComponent::Full), @@ -123,10 +96,7 @@ impl StyleComponents { } pub fn header(&self) -> bool { - self.header_filename() - || self.header_filesize() - || self.header_permissions() - || self.header_last_modified() + self.header_filename() || self.header_filesize() } pub fn header_filename(&self) -> bool { @@ -137,14 +107,6 @@ impl StyleComponents { self.0.contains(&StyleComponent::HeaderFilesize) } - pub fn header_permissions(&self) -> bool { - self.0.contains(&StyleComponent::HeaderPermissions) - } - - pub fn header_last_modified(&self) -> bool { - self.0.contains(&StyleComponent::HeaderLastModified) - } - pub fn numbers(&self) -> bool { self.0.contains(&StyleComponent::LineNumbers) } diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 5648f252cd..6d7db6dc43 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -919,30 +919,30 @@ fn empty_file_leads_to_empty_output_with_rule_enabled() { } #[test] -fn filename_basic() { +fn header_basic() { bat() .arg("test.txt") .arg("--decorations=always") - .arg("--style=header") + .arg("--style=header-filename,header-filesize") .arg("-r=0:0") .arg("--file-name=foo") .assert() .success() - .stdout("File: foo\n") + .stdout("File: foo\nSize: 12 B\n") .stderr(""); } #[test] -fn filename_binary() { +fn header_binary() { bat() .arg("test.binary") .arg("--decorations=always") - .arg("--style=header") + .arg("--style=header-filename,header-filesize") .arg("-r=0:0") .arg("--file-name=foo") .assert() .success() - .stdout("File: foo \n") + .stdout("File: foo \nSize: 4 B\n") .stderr(""); } @@ -950,7 +950,7 @@ fn filename_binary() { fn filename_stdin() { bat() .arg("--decorations=always") - .arg("--style=header") + .arg("--style=header-filename") .arg("-r=0:0") .arg("-") .write_stdin("stdin\n") @@ -966,7 +966,7 @@ fn filename_stdin_binary() { let vec = vec![0; 1]; bat_with_config() .arg("--decorations=always") - .arg("--style=header") + .arg("--style=header-filename") .write_stdin(vec) .arg("--file-name=foo") .assert() @@ -979,7 +979,7 @@ fn filename_stdin_binary() { fn filename_multiple_ok() { bat() .arg("--decorations=always") - .arg("--style=header") + .arg("--style=header-filename") .arg("-r=0:0") .arg("test.txt") .arg("--file-name=foo") @@ -995,7 +995,7 @@ fn filename_multiple_ok() { fn filename_multiple_err() { bat() .arg("--decorations=always") - .arg("--style=header") + .arg("--style=header-filename") .arg("-r=0:0") .arg("test.txt") .arg("--file-name=foo") @@ -1008,11 +1008,11 @@ fn filename_multiple_err() { fn header_padding() { bat() .arg("--decorations=always") - .arg("--style=header") + .arg("--style=header-filename,header-filesize") .arg("test.txt") .arg("single-line.txt") .assert() - .stdout("File: test.txt\nhello world\n\nFile: single-line.txt\nSingle Line\n") + .stdout("File: test.txt\nSize: 12 B\nhello world\n\nFile: single-line.txt\nSize: 11 B\nSingle Line\n") .stderr(""); } @@ -1020,16 +1020,18 @@ fn header_padding() { fn header_padding_rule() { bat() .arg("--decorations=always") - .arg("--style=header,rule") + .arg("--style=header-filename,header-filesize,rule") .arg("--terminal-width=80") .arg("test.txt") .arg("single-line.txt") .assert() .stdout( "File: test.txt +Size: 12 B hello world ──────────────────────────────────────────────────────────────────────────────── File: single-line.txt +Size: 11 B Single Line ", ) @@ -1219,6 +1221,7 @@ fn grid_for_file_without_newline() { "\ ───────┬──────────────────────────────────────────────────────────────────────── │ File: single-line.txt + │ Size: 11 B ───────┼──────────────────────────────────────────────────────────────────────── 1 │ Single Line ───────┴──────────────────────────────────────────────────────────────────────── diff --git a/tests/snapshots/output/full.snapshot.txt b/tests/snapshots/output/full.snapshot.txt index f8ecaa32c3..924b65dafb 100644 --- a/tests/snapshots/output/full.snapshot.txt +++ b/tests/snapshots/output/full.snapshot.txt @@ -1,5 +1,6 @@ ───────┬──────────────────────────────────────────────────────────────────────── │ File: sample.rs + │ Size: 533 B ───────┼──────────────────────────────────────────────────────────────────────── 1 + │ /// A rectangle. First line is changed to prevent a regression of #1869 2 │ struct Rectangle { From ef8c180bd59491abd5a23eba4604a10afe96f363 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Sat, 22 Jan 2022 13:09:29 +0000 Subject: [PATCH 09/15] rewording of --help for header styles Co-authored-by: Martin Nordholts --- src/bin/bat/clap_app.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index cc34f18c2c..7b1a9fcbc8 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -434,9 +434,9 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { * auto: same as 'full', unless the output is piped.\n \ * plain: disables all available components.\n \ * changes: show Git modification markers.\n \ - * header: show filenames before the content.\n \ - * header-filename: displays the file name.\n \ - * header-filesize: displays the size of the file in human-readable format.\n \ + * header: legacy alias for 'header-filename'.\n \ + * header-filename: show filenames before the content.\n \ + * header-filesize: show file sizes before the content.\n \ * grid: vertical/horizontal lines to separate side bar\n \ and the header from the content.\n \ * rule: horizontal lines to delimit files.\n \ From d8380ea1d1fc26e36ace973dda6801a3f9cb8744 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Mon, 24 Jan 2022 08:04:39 +0000 Subject: [PATCH 10/15] Simplify input.rs metadata Co-authored-by: Martin Nordholts --- src/input.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/input.rs b/src/input.rs index f55c0ac62a..3c295822db 100644 --- a/src/input.rs +++ b/src/input.rs @@ -132,16 +132,9 @@ impl<'a> Input<'a> { fn _ordinary_file(path: &Path) -> Self { let kind = InputKind::OrdinaryFile(path.to_path_buf()); - let metadata = match fs::metadata(path.to_path_buf()) { - Ok(meta) => { - let size = meta.len(); - - InputMetadata { - size: Some(size), - ..InputMetadata::default() - } - } - Err(_) => InputMetadata::default(), + let metadata = InputMetadata { + size: fs::metadata(path).map(|m| m.len()).ok(), + ..InputMetadata::default() }; Input { From 108a28decebb70420baa23799abcccca9692847f Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Mon, 24 Jan 2022 08:07:32 +0000 Subject: [PATCH 11/15] integration tests: copy tests for full header --- src/style.rs | 1 + tests/integration_tests.rs | 68 +++++++++++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/style.rs b/src/style.rs index 52816e8237..1bdcaba1a9 100644 --- a/src/style.rs +++ b/src/style.rs @@ -3,6 +3,7 @@ use std::str::FromStr; use crate::error::*; +#[non_exhaustive] #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)] pub enum StyleComponent { Auto, diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 6d7db6dc43..a4224c9463 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -920,6 +920,20 @@ fn empty_file_leads_to_empty_output_with_rule_enabled() { #[test] fn header_basic() { + bat() + .arg("test.txt") + .arg("--decorations=always") + .arg("--style=header") + .arg("-r=0:0") + .arg("--file-name=foo") + .assert() + .success() + .stdout("File: foo\n") + .stderr(""); +} + +#[test] +fn header_full_basic() { bat() .arg("test.txt") .arg("--decorations=always") @@ -934,6 +948,20 @@ fn header_basic() { #[test] fn header_binary() { + bat() + .arg("test.binary") + .arg("--decorations=always") + .arg("--style=header") + .arg("-r=0:0") + .arg("--file-name=foo") + .assert() + .success() + .stdout("File: foo \n") + .stderr(""); +} + +#[test] +fn header_full_binary() { bat() .arg("test.binary") .arg("--decorations=always") @@ -950,7 +978,7 @@ fn header_binary() { fn filename_stdin() { bat() .arg("--decorations=always") - .arg("--style=header-filename") + .arg("--style=header") .arg("-r=0:0") .arg("-") .write_stdin("stdin\n") @@ -966,7 +994,7 @@ fn filename_stdin_binary() { let vec = vec![0; 1]; bat_with_config() .arg("--decorations=always") - .arg("--style=header-filename") + .arg("--style=header") .write_stdin(vec) .arg("--file-name=foo") .assert() @@ -979,7 +1007,7 @@ fn filename_stdin_binary() { fn filename_multiple_ok() { bat() .arg("--decorations=always") - .arg("--style=header-filename") + .arg("--style=header") .arg("-r=0:0") .arg("test.txt") .arg("--file-name=foo") @@ -995,7 +1023,7 @@ fn filename_multiple_ok() { fn filename_multiple_err() { bat() .arg("--decorations=always") - .arg("--style=header-filename") + .arg("--style=header") .arg("-r=0:0") .arg("test.txt") .arg("--file-name=foo") @@ -1006,6 +1034,18 @@ fn filename_multiple_err() { #[test] fn header_padding() { + bat() + .arg("--decorations=always") + .arg("--style=header") + .arg("test.txt") + .arg("single-line.txt") + .assert() + .stdout("File: test.txt\nhello world\n\nFile: single-line.txt\nSingle Line\n") + .stderr(""); +} + +#[test] +fn header_full_padding() { bat() .arg("--decorations=always") .arg("--style=header-filename,header-filesize") @@ -1018,6 +1058,26 @@ fn header_padding() { #[test] fn header_padding_rule() { + bat() + .arg("--decorations=always") + .arg("--style=header,rule") + .arg("--terminal-width=80") + .arg("test.txt") + .arg("single-line.txt") + .assert() + .stdout( + "File: test.txt +hello world +──────────────────────────────────────────────────────────────────────────────── +File: single-line.txt +Single Line +", + ) + .stderr(""); +} + +#[test] +fn header_full_padding_rule() { bat() .arg("--decorations=always") .arg("--style=header-filename,header-filesize,rule") From 4284fabecaeba3432263d04e1a80113094db19cf Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Mon, 24 Jan 2022 08:25:42 +0000 Subject: [PATCH 12/15] move header component indent print to helper function --- assets/syntaxes/02_Extra/MediaWiki | 2 +- assets/syntaxes/02_Extra/ssh-config | 2 +- src/printer.rs | 47 ++++++++++++++++------------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/assets/syntaxes/02_Extra/MediaWiki b/assets/syntaxes/02_Extra/MediaWiki index 843a483e8b..81bf97cace 160000 --- a/assets/syntaxes/02_Extra/MediaWiki +++ b/assets/syntaxes/02_Extra/MediaWiki @@ -1 +1 @@ -Subproject commit 843a483e8b9f18c4ba914f29a788db5b3a87ed11 +Subproject commit 81bf97cace59bedcb1668e7830b85c36e014428e diff --git a/assets/syntaxes/02_Extra/ssh-config b/assets/syntaxes/02_Extra/ssh-config index 201816b609..e1012e9f13 160000 --- a/assets/syntaxes/02_Extra/ssh-config +++ b/assets/syntaxes/02_Extra/ssh-config @@ -1 +1 @@ -Subproject commit 201816b609abf7ccf583f7e888f6dc4121410d70 +Subproject commit e1012e9f13c6073f559b14206df2ede35720e884 diff --git a/src/printer.rs b/src/printer.rs index d0c49d3bf5..fb6cf6acd8 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -253,6 +253,21 @@ impl<'a> InteractivePrinter<'a> { } } + fn print_header_component_indent(&mut self, handle: &mut dyn Write) -> std::io::Result<()> { + if self.config.style_components.grid() { + write!( + handle, + "{}{}", + " ".repeat(self.panel_width), + self.colors + .grid + .paint(if self.panel_width > 0 { "│ " } else { "" }), + ) + } else { + write!(handle, "{}", " ".repeat(self.panel_width)) + } + } + fn preprocess(&self, text: &str, cursor: &mut usize) -> String { if self.config.tab_width > 0 { return expand_tabs(text, self.config.tab_width, cursor); @@ -290,15 +305,6 @@ impl<'a> Printer for InteractivePrinter<'a> { return Ok(()); } - if self.config.style_components.grid() { - self.print_horizontal_line(handle, '┬')?; - } else { - // Only pad space between files, if we haven't already drawn a horizontal rule - if add_header_padding && !self.config.style_components.rule() { - writeln!(handle)?; - } - } - let mode = match self.content_type { Some(ContentType::BINARY) => " ", Some(ContentType::UTF_16LE) => " ", @@ -327,19 +333,18 @@ impl<'a> Printer for InteractivePrinter<'a> { .map(|(component, _)| *component) .collect(); - header_components.iter().try_for_each(|component| { - if self.config.style_components.grid() { - write!( - handle, - "{}{}", - " ".repeat(self.panel_width), - self.colors - .grid - .paint(if self.panel_width > 0 { "│ " } else { "" }), - )?; - } else { - write!(handle, "{}", " ".repeat(self.panel_width))?; + // Print the cornering grid before the first header component + if self.config.style_components.grid() { + self.print_horizontal_line(handle, '┬')?; + } else { + // Only pad space between files, if we haven't already drawn a horizontal rule + if add_header_padding && !self.config.style_components.rule() { + writeln!(handle)?; } + } + + header_components.iter().try_for_each(|component| { + self.print_header_component_indent(handle)?; match component { StyleComponent::HeaderFilename => writeln!( From 8d45cbe874fefe8dd492f90b648117f9115ba9d7 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Thu, 27 Jan 2022 16:11:27 +0000 Subject: [PATCH 13/15] address some comments (this commit will be squashed later) --- Cargo.lock | 3 --- Cargo.toml | 2 +- src/bin/bat/clap_app.rs | 2 +- src/printer.rs | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 961b2d378f..4c17fd9026 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,9 +175,6 @@ name = "bytesize" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70" -dependencies = [ - "serde", -] [[package]] name = "cc" diff --git a/Cargo.toml b/Cargo.toml index 73bfe7214a..c6e6d894cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,7 @@ dirs-next = { version = "2.0.0", optional = true } grep-cli = { version = "0.1.6", optional = true } regex = { version = "1.0", optional = true } walkdir = { version = "2.0", optional = true } -bytesize = {version = "1.1.0", features = ["serde"]} +bytesize = {version = "1.1.0" } [dependencies.git2] version = "0.13" diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 7b1a9fcbc8..0a1a81cf8c 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -434,7 +434,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { * auto: same as 'full', unless the output is piped.\n \ * plain: disables all available components.\n \ * changes: show Git modification markers.\n \ - * header: legacy alias for 'header-filename'.\n \ + * header: alias for 'header-filename'.\n \ * header-filename: show filenames before the content.\n \ * header-filesize: show file sizes before the content.\n \ * grid: vertical/horizontal lines to separate side bar\n \ diff --git a/src/printer.rs b/src/printer.rs index fb6cf6acd8..2c70421d14 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -362,7 +362,7 @@ impl<'a> Printer for InteractivePrinter<'a> { let bsize = metadata .size .map(|s| format!("{}", ByteSize(s))) - .unwrap_or("".into()); + .unwrap_or_else(|| "-".into()); writeln!(handle, "Size: {}", self.colors.header_value.paint(bsize)) } _ => Ok(()), From 386c898c1c2409824cced46ffe74eb6bfef78774 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Thu, 27 Jan 2022 18:03:23 +0000 Subject: [PATCH 14/15] many small files benchmark --- Cargo.toml | 2 +- tests/benchmarks/many-small-files/small-file-0.txt | 1 + tests/benchmarks/many-small-files/small-file-1.txt | 1 + tests/benchmarks/many-small-files/small-file-10.txt | 1 + tests/benchmarks/many-small-files/small-file-100.txt | 1 + tests/benchmarks/many-small-files/small-file-11.txt | 1 + tests/benchmarks/many-small-files/small-file-12.txt | 1 + tests/benchmarks/many-small-files/small-file-13.txt | 1 + tests/benchmarks/many-small-files/small-file-14.txt | 1 + tests/benchmarks/many-small-files/small-file-15.txt | 1 + tests/benchmarks/many-small-files/small-file-16.txt | 1 + tests/benchmarks/many-small-files/small-file-17.txt | 1 + tests/benchmarks/many-small-files/small-file-18.txt | 1 + tests/benchmarks/many-small-files/small-file-19.txt | 1 + tests/benchmarks/many-small-files/small-file-2.txt | 1 + tests/benchmarks/many-small-files/small-file-20.txt | 1 + tests/benchmarks/many-small-files/small-file-21.txt | 1 + tests/benchmarks/many-small-files/small-file-22.txt | 1 + tests/benchmarks/many-small-files/small-file-23.txt | 1 + tests/benchmarks/many-small-files/small-file-24.txt | 1 + tests/benchmarks/many-small-files/small-file-25.txt | 1 + tests/benchmarks/many-small-files/small-file-26.txt | 1 + tests/benchmarks/many-small-files/small-file-27.txt | 1 + tests/benchmarks/many-small-files/small-file-28.txt | 1 + tests/benchmarks/many-small-files/small-file-29.txt | 1 + tests/benchmarks/many-small-files/small-file-3.txt | 1 + tests/benchmarks/many-small-files/small-file-30.txt | 1 + tests/benchmarks/many-small-files/small-file-31.txt | 1 + tests/benchmarks/many-small-files/small-file-32.txt | 1 + tests/benchmarks/many-small-files/small-file-33.txt | 1 + tests/benchmarks/many-small-files/small-file-34.txt | 1 + tests/benchmarks/many-small-files/small-file-35.txt | 1 + tests/benchmarks/many-small-files/small-file-36.txt | 1 + tests/benchmarks/many-small-files/small-file-37.txt | 1 + tests/benchmarks/many-small-files/small-file-38.txt | 1 + tests/benchmarks/many-small-files/small-file-39.txt | 1 + tests/benchmarks/many-small-files/small-file-4.txt | 1 + tests/benchmarks/many-small-files/small-file-40.txt | 1 + tests/benchmarks/many-small-files/small-file-41.txt | 1 + tests/benchmarks/many-small-files/small-file-42.txt | 1 + tests/benchmarks/many-small-files/small-file-43.txt | 1 + tests/benchmarks/many-small-files/small-file-44.txt | 1 + tests/benchmarks/many-small-files/small-file-45.txt | 1 + tests/benchmarks/many-small-files/small-file-46.txt | 1 + tests/benchmarks/many-small-files/small-file-47.txt | 1 + tests/benchmarks/many-small-files/small-file-48.txt | 1 + tests/benchmarks/many-small-files/small-file-49.txt | 1 + tests/benchmarks/many-small-files/small-file-5.txt | 1 + tests/benchmarks/many-small-files/small-file-50.txt | 1 + tests/benchmarks/many-small-files/small-file-51.txt | 1 + tests/benchmarks/many-small-files/small-file-52.txt | 1 + tests/benchmarks/many-small-files/small-file-53.txt | 1 + tests/benchmarks/many-small-files/small-file-54.txt | 1 + tests/benchmarks/many-small-files/small-file-55.txt | 1 + tests/benchmarks/many-small-files/small-file-56.txt | 1 + tests/benchmarks/many-small-files/small-file-57.txt | 1 + tests/benchmarks/many-small-files/small-file-58.txt | 1 + tests/benchmarks/many-small-files/small-file-59.txt | 1 + tests/benchmarks/many-small-files/small-file-6.txt | 1 + tests/benchmarks/many-small-files/small-file-60.txt | 1 + tests/benchmarks/many-small-files/small-file-61.txt | 1 + tests/benchmarks/many-small-files/small-file-62.txt | 1 + tests/benchmarks/many-small-files/small-file-63.txt | 1 + tests/benchmarks/many-small-files/small-file-64.txt | 1 + tests/benchmarks/many-small-files/small-file-65.txt | 1 + tests/benchmarks/many-small-files/small-file-66.txt | 1 + tests/benchmarks/many-small-files/small-file-67.txt | 1 + tests/benchmarks/many-small-files/small-file-68.txt | 1 + tests/benchmarks/many-small-files/small-file-69.txt | 1 + tests/benchmarks/many-small-files/small-file-7.txt | 1 + tests/benchmarks/many-small-files/small-file-70.txt | 1 + tests/benchmarks/many-small-files/small-file-71.txt | 1 + tests/benchmarks/many-small-files/small-file-72.txt | 1 + tests/benchmarks/many-small-files/small-file-73.txt | 1 + tests/benchmarks/many-small-files/small-file-74.txt | 1 + tests/benchmarks/many-small-files/small-file-75.txt | 1 + tests/benchmarks/many-small-files/small-file-76.txt | 1 + tests/benchmarks/many-small-files/small-file-77.txt | 1 + tests/benchmarks/many-small-files/small-file-78.txt | 1 + tests/benchmarks/many-small-files/small-file-79.txt | 1 + tests/benchmarks/many-small-files/small-file-8.txt | 1 + tests/benchmarks/many-small-files/small-file-80.txt | 1 + tests/benchmarks/many-small-files/small-file-81.txt | 1 + tests/benchmarks/many-small-files/small-file-82.txt | 1 + tests/benchmarks/many-small-files/small-file-83.txt | 1 + tests/benchmarks/many-small-files/small-file-84.txt | 1 + tests/benchmarks/many-small-files/small-file-85.txt | 1 + tests/benchmarks/many-small-files/small-file-86.txt | 1 + tests/benchmarks/many-small-files/small-file-87.txt | 1 + tests/benchmarks/many-small-files/small-file-88.txt | 1 + tests/benchmarks/many-small-files/small-file-89.txt | 1 + tests/benchmarks/many-small-files/small-file-9.txt | 1 + tests/benchmarks/many-small-files/small-file-90.txt | 1 + tests/benchmarks/many-small-files/small-file-91.txt | 1 + tests/benchmarks/many-small-files/small-file-92.txt | 1 + tests/benchmarks/many-small-files/small-file-93.txt | 1 + tests/benchmarks/many-small-files/small-file-94.txt | 1 + tests/benchmarks/many-small-files/small-file-95.txt | 1 + tests/benchmarks/many-small-files/small-file-96.txt | 1 + tests/benchmarks/many-small-files/small-file-97.txt | 1 + tests/benchmarks/many-small-files/small-file-98.txt | 1 + tests/benchmarks/many-small-files/small-file-99.txt | 1 + tests/benchmarks/run-benchmarks.sh | 10 ++++++++++ 103 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 tests/benchmarks/many-small-files/small-file-0.txt create mode 100644 tests/benchmarks/many-small-files/small-file-1.txt create mode 100644 tests/benchmarks/many-small-files/small-file-10.txt create mode 100644 tests/benchmarks/many-small-files/small-file-100.txt create mode 100644 tests/benchmarks/many-small-files/small-file-11.txt create mode 100644 tests/benchmarks/many-small-files/small-file-12.txt create mode 100644 tests/benchmarks/many-small-files/small-file-13.txt create mode 100644 tests/benchmarks/many-small-files/small-file-14.txt create mode 100644 tests/benchmarks/many-small-files/small-file-15.txt create mode 100644 tests/benchmarks/many-small-files/small-file-16.txt create mode 100644 tests/benchmarks/many-small-files/small-file-17.txt create mode 100644 tests/benchmarks/many-small-files/small-file-18.txt create mode 100644 tests/benchmarks/many-small-files/small-file-19.txt create mode 100644 tests/benchmarks/many-small-files/small-file-2.txt create mode 100644 tests/benchmarks/many-small-files/small-file-20.txt create mode 100644 tests/benchmarks/many-small-files/small-file-21.txt create mode 100644 tests/benchmarks/many-small-files/small-file-22.txt create mode 100644 tests/benchmarks/many-small-files/small-file-23.txt create mode 100644 tests/benchmarks/many-small-files/small-file-24.txt create mode 100644 tests/benchmarks/many-small-files/small-file-25.txt create mode 100644 tests/benchmarks/many-small-files/small-file-26.txt create mode 100644 tests/benchmarks/many-small-files/small-file-27.txt create mode 100644 tests/benchmarks/many-small-files/small-file-28.txt create mode 100644 tests/benchmarks/many-small-files/small-file-29.txt create mode 100644 tests/benchmarks/many-small-files/small-file-3.txt create mode 100644 tests/benchmarks/many-small-files/small-file-30.txt create mode 100644 tests/benchmarks/many-small-files/small-file-31.txt create mode 100644 tests/benchmarks/many-small-files/small-file-32.txt create mode 100644 tests/benchmarks/many-small-files/small-file-33.txt create mode 100644 tests/benchmarks/many-small-files/small-file-34.txt create mode 100644 tests/benchmarks/many-small-files/small-file-35.txt create mode 100644 tests/benchmarks/many-small-files/small-file-36.txt create mode 100644 tests/benchmarks/many-small-files/small-file-37.txt create mode 100644 tests/benchmarks/many-small-files/small-file-38.txt create mode 100644 tests/benchmarks/many-small-files/small-file-39.txt create mode 100644 tests/benchmarks/many-small-files/small-file-4.txt create mode 100644 tests/benchmarks/many-small-files/small-file-40.txt create mode 100644 tests/benchmarks/many-small-files/small-file-41.txt create mode 100644 tests/benchmarks/many-small-files/small-file-42.txt create mode 100644 tests/benchmarks/many-small-files/small-file-43.txt create mode 100644 tests/benchmarks/many-small-files/small-file-44.txt create mode 100644 tests/benchmarks/many-small-files/small-file-45.txt create mode 100644 tests/benchmarks/many-small-files/small-file-46.txt create mode 100644 tests/benchmarks/many-small-files/small-file-47.txt create mode 100644 tests/benchmarks/many-small-files/small-file-48.txt create mode 100644 tests/benchmarks/many-small-files/small-file-49.txt create mode 100644 tests/benchmarks/many-small-files/small-file-5.txt create mode 100644 tests/benchmarks/many-small-files/small-file-50.txt create mode 100644 tests/benchmarks/many-small-files/small-file-51.txt create mode 100644 tests/benchmarks/many-small-files/small-file-52.txt create mode 100644 tests/benchmarks/many-small-files/small-file-53.txt create mode 100644 tests/benchmarks/many-small-files/small-file-54.txt create mode 100644 tests/benchmarks/many-small-files/small-file-55.txt create mode 100644 tests/benchmarks/many-small-files/small-file-56.txt create mode 100644 tests/benchmarks/many-small-files/small-file-57.txt create mode 100644 tests/benchmarks/many-small-files/small-file-58.txt create mode 100644 tests/benchmarks/many-small-files/small-file-59.txt create mode 100644 tests/benchmarks/many-small-files/small-file-6.txt create mode 100644 tests/benchmarks/many-small-files/small-file-60.txt create mode 100644 tests/benchmarks/many-small-files/small-file-61.txt create mode 100644 tests/benchmarks/many-small-files/small-file-62.txt create mode 100644 tests/benchmarks/many-small-files/small-file-63.txt create mode 100644 tests/benchmarks/many-small-files/small-file-64.txt create mode 100644 tests/benchmarks/many-small-files/small-file-65.txt create mode 100644 tests/benchmarks/many-small-files/small-file-66.txt create mode 100644 tests/benchmarks/many-small-files/small-file-67.txt create mode 100644 tests/benchmarks/many-small-files/small-file-68.txt create mode 100644 tests/benchmarks/many-small-files/small-file-69.txt create mode 100644 tests/benchmarks/many-small-files/small-file-7.txt create mode 100644 tests/benchmarks/many-small-files/small-file-70.txt create mode 100644 tests/benchmarks/many-small-files/small-file-71.txt create mode 100644 tests/benchmarks/many-small-files/small-file-72.txt create mode 100644 tests/benchmarks/many-small-files/small-file-73.txt create mode 100644 tests/benchmarks/many-small-files/small-file-74.txt create mode 100644 tests/benchmarks/many-small-files/small-file-75.txt create mode 100644 tests/benchmarks/many-small-files/small-file-76.txt create mode 100644 tests/benchmarks/many-small-files/small-file-77.txt create mode 100644 tests/benchmarks/many-small-files/small-file-78.txt create mode 100644 tests/benchmarks/many-small-files/small-file-79.txt create mode 100644 tests/benchmarks/many-small-files/small-file-8.txt create mode 100644 tests/benchmarks/many-small-files/small-file-80.txt create mode 100644 tests/benchmarks/many-small-files/small-file-81.txt create mode 100644 tests/benchmarks/many-small-files/small-file-82.txt create mode 100644 tests/benchmarks/many-small-files/small-file-83.txt create mode 100644 tests/benchmarks/many-small-files/small-file-84.txt create mode 100644 tests/benchmarks/many-small-files/small-file-85.txt create mode 100644 tests/benchmarks/many-small-files/small-file-86.txt create mode 100644 tests/benchmarks/many-small-files/small-file-87.txt create mode 100644 tests/benchmarks/many-small-files/small-file-88.txt create mode 100644 tests/benchmarks/many-small-files/small-file-89.txt create mode 100644 tests/benchmarks/many-small-files/small-file-9.txt create mode 100644 tests/benchmarks/many-small-files/small-file-90.txt create mode 100644 tests/benchmarks/many-small-files/small-file-91.txt create mode 100644 tests/benchmarks/many-small-files/small-file-92.txt create mode 100644 tests/benchmarks/many-small-files/small-file-93.txt create mode 100644 tests/benchmarks/many-small-files/small-file-94.txt create mode 100644 tests/benchmarks/many-small-files/small-file-95.txt create mode 100644 tests/benchmarks/many-small-files/small-file-96.txt create mode 100644 tests/benchmarks/many-small-files/small-file-97.txt create mode 100644 tests/benchmarks/many-small-files/small-file-98.txt create mode 100644 tests/benchmarks/many-small-files/small-file-99.txt diff --git a/Cargo.toml b/Cargo.toml index c6e6d894cc..99a6564289 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,7 @@ dirs-next = { version = "2.0.0", optional = true } grep-cli = { version = "0.1.6", optional = true } regex = { version = "1.0", optional = true } walkdir = { version = "2.0", optional = true } -bytesize = {version = "1.1.0" } +bytesize = { version = "1.1.0" } [dependencies.git2] version = "0.13" diff --git a/tests/benchmarks/many-small-files/small-file-0.txt b/tests/benchmarks/many-small-files/small-file-0.txt new file mode 100644 index 0000000000..c37ced692b --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-0.txt @@ -0,0 +1 @@ +I am small file 0 diff --git a/tests/benchmarks/many-small-files/small-file-1.txt b/tests/benchmarks/many-small-files/small-file-1.txt new file mode 100644 index 0000000000..a34435e5f9 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-1.txt @@ -0,0 +1 @@ +I am small file 1 diff --git a/tests/benchmarks/many-small-files/small-file-10.txt b/tests/benchmarks/many-small-files/small-file-10.txt new file mode 100644 index 0000000000..44d0741731 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-10.txt @@ -0,0 +1 @@ +I am small file 10 diff --git a/tests/benchmarks/many-small-files/small-file-100.txt b/tests/benchmarks/many-small-files/small-file-100.txt new file mode 100644 index 0000000000..d0aee2f44d --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-100.txt @@ -0,0 +1 @@ +I am small file 100 diff --git a/tests/benchmarks/many-small-files/small-file-11.txt b/tests/benchmarks/many-small-files/small-file-11.txt new file mode 100644 index 0000000000..5e8b37a383 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-11.txt @@ -0,0 +1 @@ +I am small file 11 diff --git a/tests/benchmarks/many-small-files/small-file-12.txt b/tests/benchmarks/many-small-files/small-file-12.txt new file mode 100644 index 0000000000..ffed221aa6 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-12.txt @@ -0,0 +1 @@ +I am small file 12 diff --git a/tests/benchmarks/many-small-files/small-file-13.txt b/tests/benchmarks/many-small-files/small-file-13.txt new file mode 100644 index 0000000000..bce7798149 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-13.txt @@ -0,0 +1 @@ +I am small file 13 diff --git a/tests/benchmarks/many-small-files/small-file-14.txt b/tests/benchmarks/many-small-files/small-file-14.txt new file mode 100644 index 0000000000..290d2284ef --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-14.txt @@ -0,0 +1 @@ +I am small file 14 diff --git a/tests/benchmarks/many-small-files/small-file-15.txt b/tests/benchmarks/many-small-files/small-file-15.txt new file mode 100644 index 0000000000..2b148c7a6f --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-15.txt @@ -0,0 +1 @@ +I am small file 15 diff --git a/tests/benchmarks/many-small-files/small-file-16.txt b/tests/benchmarks/many-small-files/small-file-16.txt new file mode 100644 index 0000000000..ec88108f66 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-16.txt @@ -0,0 +1 @@ +I am small file 16 diff --git a/tests/benchmarks/many-small-files/small-file-17.txt b/tests/benchmarks/many-small-files/small-file-17.txt new file mode 100644 index 0000000000..a1dafea0af --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-17.txt @@ -0,0 +1 @@ +I am small file 17 diff --git a/tests/benchmarks/many-small-files/small-file-18.txt b/tests/benchmarks/many-small-files/small-file-18.txt new file mode 100644 index 0000000000..2aea21b0b7 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-18.txt @@ -0,0 +1 @@ +I am small file 18 diff --git a/tests/benchmarks/many-small-files/small-file-19.txt b/tests/benchmarks/many-small-files/small-file-19.txt new file mode 100644 index 0000000000..812c5eebf4 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-19.txt @@ -0,0 +1 @@ +I am small file 19 diff --git a/tests/benchmarks/many-small-files/small-file-2.txt b/tests/benchmarks/many-small-files/small-file-2.txt new file mode 100644 index 0000000000..914af6b8b4 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-2.txt @@ -0,0 +1 @@ +I am small file 2 diff --git a/tests/benchmarks/many-small-files/small-file-20.txt b/tests/benchmarks/many-small-files/small-file-20.txt new file mode 100644 index 0000000000..f9822cb83d --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-20.txt @@ -0,0 +1 @@ +I am small file 20 diff --git a/tests/benchmarks/many-small-files/small-file-21.txt b/tests/benchmarks/many-small-files/small-file-21.txt new file mode 100644 index 0000000000..ad61008d6e --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-21.txt @@ -0,0 +1 @@ +I am small file 21 diff --git a/tests/benchmarks/many-small-files/small-file-22.txt b/tests/benchmarks/many-small-files/small-file-22.txt new file mode 100644 index 0000000000..39f0791eff --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-22.txt @@ -0,0 +1 @@ +I am small file 22 diff --git a/tests/benchmarks/many-small-files/small-file-23.txt b/tests/benchmarks/many-small-files/small-file-23.txt new file mode 100644 index 0000000000..6e0868df55 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-23.txt @@ -0,0 +1 @@ +I am small file 23 diff --git a/tests/benchmarks/many-small-files/small-file-24.txt b/tests/benchmarks/many-small-files/small-file-24.txt new file mode 100644 index 0000000000..08e21c069f --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-24.txt @@ -0,0 +1 @@ +I am small file 24 diff --git a/tests/benchmarks/many-small-files/small-file-25.txt b/tests/benchmarks/many-small-files/small-file-25.txt new file mode 100644 index 0000000000..feffff3044 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-25.txt @@ -0,0 +1 @@ +I am small file 25 diff --git a/tests/benchmarks/many-small-files/small-file-26.txt b/tests/benchmarks/many-small-files/small-file-26.txt new file mode 100644 index 0000000000..075a7089c4 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-26.txt @@ -0,0 +1 @@ +I am small file 26 diff --git a/tests/benchmarks/many-small-files/small-file-27.txt b/tests/benchmarks/many-small-files/small-file-27.txt new file mode 100644 index 0000000000..812e0937fc --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-27.txt @@ -0,0 +1 @@ +I am small file 27 diff --git a/tests/benchmarks/many-small-files/small-file-28.txt b/tests/benchmarks/many-small-files/small-file-28.txt new file mode 100644 index 0000000000..188aa0b876 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-28.txt @@ -0,0 +1 @@ +I am small file 28 diff --git a/tests/benchmarks/many-small-files/small-file-29.txt b/tests/benchmarks/many-small-files/small-file-29.txt new file mode 100644 index 0000000000..bb779a6eb0 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-29.txt @@ -0,0 +1 @@ +I am small file 29 diff --git a/tests/benchmarks/many-small-files/small-file-3.txt b/tests/benchmarks/many-small-files/small-file-3.txt new file mode 100644 index 0000000000..d4605ecf6b --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-3.txt @@ -0,0 +1 @@ +I am small file 3 diff --git a/tests/benchmarks/many-small-files/small-file-30.txt b/tests/benchmarks/many-small-files/small-file-30.txt new file mode 100644 index 0000000000..cb748f3c3f --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-30.txt @@ -0,0 +1 @@ +I am small file 30 diff --git a/tests/benchmarks/many-small-files/small-file-31.txt b/tests/benchmarks/many-small-files/small-file-31.txt new file mode 100644 index 0000000000..d6a7a357ec --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-31.txt @@ -0,0 +1 @@ +I am small file 31 diff --git a/tests/benchmarks/many-small-files/small-file-32.txt b/tests/benchmarks/many-small-files/small-file-32.txt new file mode 100644 index 0000000000..e9d13ee038 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-32.txt @@ -0,0 +1 @@ +I am small file 32 diff --git a/tests/benchmarks/many-small-files/small-file-33.txt b/tests/benchmarks/many-small-files/small-file-33.txt new file mode 100644 index 0000000000..1c5284da7d --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-33.txt @@ -0,0 +1 @@ +I am small file 33 diff --git a/tests/benchmarks/many-small-files/small-file-34.txt b/tests/benchmarks/many-small-files/small-file-34.txt new file mode 100644 index 0000000000..6364d4c881 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-34.txt @@ -0,0 +1 @@ +I am small file 34 diff --git a/tests/benchmarks/many-small-files/small-file-35.txt b/tests/benchmarks/many-small-files/small-file-35.txt new file mode 100644 index 0000000000..6a4a6bea7c --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-35.txt @@ -0,0 +1 @@ +I am small file 35 diff --git a/tests/benchmarks/many-small-files/small-file-36.txt b/tests/benchmarks/many-small-files/small-file-36.txt new file mode 100644 index 0000000000..c7f23947a7 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-36.txt @@ -0,0 +1 @@ +I am small file 36 diff --git a/tests/benchmarks/many-small-files/small-file-37.txt b/tests/benchmarks/many-small-files/small-file-37.txt new file mode 100644 index 0000000000..2bdbdad205 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-37.txt @@ -0,0 +1 @@ +I am small file 37 diff --git a/tests/benchmarks/many-small-files/small-file-38.txt b/tests/benchmarks/many-small-files/small-file-38.txt new file mode 100644 index 0000000000..cff8f8c5b5 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-38.txt @@ -0,0 +1 @@ +I am small file 38 diff --git a/tests/benchmarks/many-small-files/small-file-39.txt b/tests/benchmarks/many-small-files/small-file-39.txt new file mode 100644 index 0000000000..1a31a10d07 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-39.txt @@ -0,0 +1 @@ +I am small file 39 diff --git a/tests/benchmarks/many-small-files/small-file-4.txt b/tests/benchmarks/many-small-files/small-file-4.txt new file mode 100644 index 0000000000..f882bfd910 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-4.txt @@ -0,0 +1 @@ +I am small file 4 diff --git a/tests/benchmarks/many-small-files/small-file-40.txt b/tests/benchmarks/many-small-files/small-file-40.txt new file mode 100644 index 0000000000..192abfbd6c --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-40.txt @@ -0,0 +1 @@ +I am small file 40 diff --git a/tests/benchmarks/many-small-files/small-file-41.txt b/tests/benchmarks/many-small-files/small-file-41.txt new file mode 100644 index 0000000000..f2a6fe8e06 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-41.txt @@ -0,0 +1 @@ +I am small file 41 diff --git a/tests/benchmarks/many-small-files/small-file-42.txt b/tests/benchmarks/many-small-files/small-file-42.txt new file mode 100644 index 0000000000..f091e63119 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-42.txt @@ -0,0 +1 @@ +I am small file 42 diff --git a/tests/benchmarks/many-small-files/small-file-43.txt b/tests/benchmarks/many-small-files/small-file-43.txt new file mode 100644 index 0000000000..8f5c4181be --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-43.txt @@ -0,0 +1 @@ +I am small file 43 diff --git a/tests/benchmarks/many-small-files/small-file-44.txt b/tests/benchmarks/many-small-files/small-file-44.txt new file mode 100644 index 0000000000..6b69df5f77 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-44.txt @@ -0,0 +1 @@ +I am small file 44 diff --git a/tests/benchmarks/many-small-files/small-file-45.txt b/tests/benchmarks/many-small-files/small-file-45.txt new file mode 100644 index 0000000000..56ca9062ae --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-45.txt @@ -0,0 +1 @@ +I am small file 45 diff --git a/tests/benchmarks/many-small-files/small-file-46.txt b/tests/benchmarks/many-small-files/small-file-46.txt new file mode 100644 index 0000000000..9ecad26cbd --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-46.txt @@ -0,0 +1 @@ +I am small file 46 diff --git a/tests/benchmarks/many-small-files/small-file-47.txt b/tests/benchmarks/many-small-files/small-file-47.txt new file mode 100644 index 0000000000..a46606cd0c --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-47.txt @@ -0,0 +1 @@ +I am small file 47 diff --git a/tests/benchmarks/many-small-files/small-file-48.txt b/tests/benchmarks/many-small-files/small-file-48.txt new file mode 100644 index 0000000000..9e4b70a0ce --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-48.txt @@ -0,0 +1 @@ +I am small file 48 diff --git a/tests/benchmarks/many-small-files/small-file-49.txt b/tests/benchmarks/many-small-files/small-file-49.txt new file mode 100644 index 0000000000..6da8a669a2 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-49.txt @@ -0,0 +1 @@ +I am small file 49 diff --git a/tests/benchmarks/many-small-files/small-file-5.txt b/tests/benchmarks/many-small-files/small-file-5.txt new file mode 100644 index 0000000000..9f4cbecc94 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-5.txt @@ -0,0 +1 @@ +I am small file 5 diff --git a/tests/benchmarks/many-small-files/small-file-50.txt b/tests/benchmarks/many-small-files/small-file-50.txt new file mode 100644 index 0000000000..24a9be1000 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-50.txt @@ -0,0 +1 @@ +I am small file 50 diff --git a/tests/benchmarks/many-small-files/small-file-51.txt b/tests/benchmarks/many-small-files/small-file-51.txt new file mode 100644 index 0000000000..070eccf7e9 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-51.txt @@ -0,0 +1 @@ +I am small file 51 diff --git a/tests/benchmarks/many-small-files/small-file-52.txt b/tests/benchmarks/many-small-files/small-file-52.txt new file mode 100644 index 0000000000..aebee16c50 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-52.txt @@ -0,0 +1 @@ +I am small file 52 diff --git a/tests/benchmarks/many-small-files/small-file-53.txt b/tests/benchmarks/many-small-files/small-file-53.txt new file mode 100644 index 0000000000..b61a4a478d --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-53.txt @@ -0,0 +1 @@ +I am small file 53 diff --git a/tests/benchmarks/many-small-files/small-file-54.txt b/tests/benchmarks/many-small-files/small-file-54.txt new file mode 100644 index 0000000000..d8e5b908d3 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-54.txt @@ -0,0 +1 @@ +I am small file 54 diff --git a/tests/benchmarks/many-small-files/small-file-55.txt b/tests/benchmarks/many-small-files/small-file-55.txt new file mode 100644 index 0000000000..bc32b3e020 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-55.txt @@ -0,0 +1 @@ +I am small file 55 diff --git a/tests/benchmarks/many-small-files/small-file-56.txt b/tests/benchmarks/many-small-files/small-file-56.txt new file mode 100644 index 0000000000..966f19878d --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-56.txt @@ -0,0 +1 @@ +I am small file 56 diff --git a/tests/benchmarks/many-small-files/small-file-57.txt b/tests/benchmarks/many-small-files/small-file-57.txt new file mode 100644 index 0000000000..6cd916a2cf --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-57.txt @@ -0,0 +1 @@ +I am small file 57 diff --git a/tests/benchmarks/many-small-files/small-file-58.txt b/tests/benchmarks/many-small-files/small-file-58.txt new file mode 100644 index 0000000000..62e7289c10 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-58.txt @@ -0,0 +1 @@ +I am small file 58 diff --git a/tests/benchmarks/many-small-files/small-file-59.txt b/tests/benchmarks/many-small-files/small-file-59.txt new file mode 100644 index 0000000000..cde1672bc2 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-59.txt @@ -0,0 +1 @@ +I am small file 59 diff --git a/tests/benchmarks/many-small-files/small-file-6.txt b/tests/benchmarks/many-small-files/small-file-6.txt new file mode 100644 index 0000000000..0442155537 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-6.txt @@ -0,0 +1 @@ +I am small file 6 diff --git a/tests/benchmarks/many-small-files/small-file-60.txt b/tests/benchmarks/many-small-files/small-file-60.txt new file mode 100644 index 0000000000..7f32cc284b --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-60.txt @@ -0,0 +1 @@ +I am small file 60 diff --git a/tests/benchmarks/many-small-files/small-file-61.txt b/tests/benchmarks/many-small-files/small-file-61.txt new file mode 100644 index 0000000000..1ffcebfa35 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-61.txt @@ -0,0 +1 @@ +I am small file 61 diff --git a/tests/benchmarks/many-small-files/small-file-62.txt b/tests/benchmarks/many-small-files/small-file-62.txt new file mode 100644 index 0000000000..0637cb652f --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-62.txt @@ -0,0 +1 @@ +I am small file 62 diff --git a/tests/benchmarks/many-small-files/small-file-63.txt b/tests/benchmarks/many-small-files/small-file-63.txt new file mode 100644 index 0000000000..ca52a5e921 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-63.txt @@ -0,0 +1 @@ +I am small file 63 diff --git a/tests/benchmarks/many-small-files/small-file-64.txt b/tests/benchmarks/many-small-files/small-file-64.txt new file mode 100644 index 0000000000..0b0184fa68 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-64.txt @@ -0,0 +1 @@ +I am small file 64 diff --git a/tests/benchmarks/many-small-files/small-file-65.txt b/tests/benchmarks/many-small-files/small-file-65.txt new file mode 100644 index 0000000000..6502e2e4e5 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-65.txt @@ -0,0 +1 @@ +I am small file 65 diff --git a/tests/benchmarks/many-small-files/small-file-66.txt b/tests/benchmarks/many-small-files/small-file-66.txt new file mode 100644 index 0000000000..8d1e271941 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-66.txt @@ -0,0 +1 @@ +I am small file 66 diff --git a/tests/benchmarks/many-small-files/small-file-67.txt b/tests/benchmarks/many-small-files/small-file-67.txt new file mode 100644 index 0000000000..fcaf92e316 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-67.txt @@ -0,0 +1 @@ +I am small file 67 diff --git a/tests/benchmarks/many-small-files/small-file-68.txt b/tests/benchmarks/many-small-files/small-file-68.txt new file mode 100644 index 0000000000..11666f15d8 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-68.txt @@ -0,0 +1 @@ +I am small file 68 diff --git a/tests/benchmarks/many-small-files/small-file-69.txt b/tests/benchmarks/many-small-files/small-file-69.txt new file mode 100644 index 0000000000..c342b007e9 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-69.txt @@ -0,0 +1 @@ +I am small file 69 diff --git a/tests/benchmarks/many-small-files/small-file-7.txt b/tests/benchmarks/many-small-files/small-file-7.txt new file mode 100644 index 0000000000..4406b5a457 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-7.txt @@ -0,0 +1 @@ +I am small file 7 diff --git a/tests/benchmarks/many-small-files/small-file-70.txt b/tests/benchmarks/many-small-files/small-file-70.txt new file mode 100644 index 0000000000..2002f08729 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-70.txt @@ -0,0 +1 @@ +I am small file 70 diff --git a/tests/benchmarks/many-small-files/small-file-71.txt b/tests/benchmarks/many-small-files/small-file-71.txt new file mode 100644 index 0000000000..289d86966e --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-71.txt @@ -0,0 +1 @@ +I am small file 71 diff --git a/tests/benchmarks/many-small-files/small-file-72.txt b/tests/benchmarks/many-small-files/small-file-72.txt new file mode 100644 index 0000000000..cf587a9470 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-72.txt @@ -0,0 +1 @@ +I am small file 72 diff --git a/tests/benchmarks/many-small-files/small-file-73.txt b/tests/benchmarks/many-small-files/small-file-73.txt new file mode 100644 index 0000000000..22f409060b --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-73.txt @@ -0,0 +1 @@ +I am small file 73 diff --git a/tests/benchmarks/many-small-files/small-file-74.txt b/tests/benchmarks/many-small-files/small-file-74.txt new file mode 100644 index 0000000000..82da6ab564 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-74.txt @@ -0,0 +1 @@ +I am small file 74 diff --git a/tests/benchmarks/many-small-files/small-file-75.txt b/tests/benchmarks/many-small-files/small-file-75.txt new file mode 100644 index 0000000000..90974dacfc --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-75.txt @@ -0,0 +1 @@ +I am small file 75 diff --git a/tests/benchmarks/many-small-files/small-file-76.txt b/tests/benchmarks/many-small-files/small-file-76.txt new file mode 100644 index 0000000000..401af17e63 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-76.txt @@ -0,0 +1 @@ +I am small file 76 diff --git a/tests/benchmarks/many-small-files/small-file-77.txt b/tests/benchmarks/many-small-files/small-file-77.txt new file mode 100644 index 0000000000..2c8c8fbe0a --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-77.txt @@ -0,0 +1 @@ +I am small file 77 diff --git a/tests/benchmarks/many-small-files/small-file-78.txt b/tests/benchmarks/many-small-files/small-file-78.txt new file mode 100644 index 0000000000..5ade3992d0 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-78.txt @@ -0,0 +1 @@ +I am small file 78 diff --git a/tests/benchmarks/many-small-files/small-file-79.txt b/tests/benchmarks/many-small-files/small-file-79.txt new file mode 100644 index 0000000000..1b72241dde --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-79.txt @@ -0,0 +1 @@ +I am small file 79 diff --git a/tests/benchmarks/many-small-files/small-file-8.txt b/tests/benchmarks/many-small-files/small-file-8.txt new file mode 100644 index 0000000000..dd788d7976 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-8.txt @@ -0,0 +1 @@ +I am small file 8 diff --git a/tests/benchmarks/many-small-files/small-file-80.txt b/tests/benchmarks/many-small-files/small-file-80.txt new file mode 100644 index 0000000000..a3e48ad4c2 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-80.txt @@ -0,0 +1 @@ +I am small file 80 diff --git a/tests/benchmarks/many-small-files/small-file-81.txt b/tests/benchmarks/many-small-files/small-file-81.txt new file mode 100644 index 0000000000..00d5991c60 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-81.txt @@ -0,0 +1 @@ +I am small file 81 diff --git a/tests/benchmarks/many-small-files/small-file-82.txt b/tests/benchmarks/many-small-files/small-file-82.txt new file mode 100644 index 0000000000..4a3a122d0d --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-82.txt @@ -0,0 +1 @@ +I am small file 82 diff --git a/tests/benchmarks/many-small-files/small-file-83.txt b/tests/benchmarks/many-small-files/small-file-83.txt new file mode 100644 index 0000000000..31e322b9ca --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-83.txt @@ -0,0 +1 @@ +I am small file 83 diff --git a/tests/benchmarks/many-small-files/small-file-84.txt b/tests/benchmarks/many-small-files/small-file-84.txt new file mode 100644 index 0000000000..f1cffa1212 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-84.txt @@ -0,0 +1 @@ +I am small file 84 diff --git a/tests/benchmarks/many-small-files/small-file-85.txt b/tests/benchmarks/many-small-files/small-file-85.txt new file mode 100644 index 0000000000..80d6d1d39a --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-85.txt @@ -0,0 +1 @@ +I am small file 85 diff --git a/tests/benchmarks/many-small-files/small-file-86.txt b/tests/benchmarks/many-small-files/small-file-86.txt new file mode 100644 index 0000000000..82fcebdfdf --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-86.txt @@ -0,0 +1 @@ +I am small file 86 diff --git a/tests/benchmarks/many-small-files/small-file-87.txt b/tests/benchmarks/many-small-files/small-file-87.txt new file mode 100644 index 0000000000..c476c7dc5e --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-87.txt @@ -0,0 +1 @@ +I am small file 87 diff --git a/tests/benchmarks/many-small-files/small-file-88.txt b/tests/benchmarks/many-small-files/small-file-88.txt new file mode 100644 index 0000000000..0a984d3109 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-88.txt @@ -0,0 +1 @@ +I am small file 88 diff --git a/tests/benchmarks/many-small-files/small-file-89.txt b/tests/benchmarks/many-small-files/small-file-89.txt new file mode 100644 index 0000000000..8bbd9b7ef3 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-89.txt @@ -0,0 +1 @@ +I am small file 89 diff --git a/tests/benchmarks/many-small-files/small-file-9.txt b/tests/benchmarks/many-small-files/small-file-9.txt new file mode 100644 index 0000000000..10832c17eb --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-9.txt @@ -0,0 +1 @@ +I am small file 9 diff --git a/tests/benchmarks/many-small-files/small-file-90.txt b/tests/benchmarks/many-small-files/small-file-90.txt new file mode 100644 index 0000000000..72c35dfb79 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-90.txt @@ -0,0 +1 @@ +I am small file 90 diff --git a/tests/benchmarks/many-small-files/small-file-91.txt b/tests/benchmarks/many-small-files/small-file-91.txt new file mode 100644 index 0000000000..e9ad0fa8da --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-91.txt @@ -0,0 +1 @@ +I am small file 91 diff --git a/tests/benchmarks/many-small-files/small-file-92.txt b/tests/benchmarks/many-small-files/small-file-92.txt new file mode 100644 index 0000000000..ac1be6107b --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-92.txt @@ -0,0 +1 @@ +I am small file 92 diff --git a/tests/benchmarks/many-small-files/small-file-93.txt b/tests/benchmarks/many-small-files/small-file-93.txt new file mode 100644 index 0000000000..019e2ef89d --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-93.txt @@ -0,0 +1 @@ +I am small file 93 diff --git a/tests/benchmarks/many-small-files/small-file-94.txt b/tests/benchmarks/many-small-files/small-file-94.txt new file mode 100644 index 0000000000..bfc1150d29 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-94.txt @@ -0,0 +1 @@ +I am small file 94 diff --git a/tests/benchmarks/many-small-files/small-file-95.txt b/tests/benchmarks/many-small-files/small-file-95.txt new file mode 100644 index 0000000000..2dbb3e72b1 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-95.txt @@ -0,0 +1 @@ +I am small file 95 diff --git a/tests/benchmarks/many-small-files/small-file-96.txt b/tests/benchmarks/many-small-files/small-file-96.txt new file mode 100644 index 0000000000..5c244ad8cd --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-96.txt @@ -0,0 +1 @@ +I am small file 96 diff --git a/tests/benchmarks/many-small-files/small-file-97.txt b/tests/benchmarks/many-small-files/small-file-97.txt new file mode 100644 index 0000000000..44e4b98b90 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-97.txt @@ -0,0 +1 @@ +I am small file 97 diff --git a/tests/benchmarks/many-small-files/small-file-98.txt b/tests/benchmarks/many-small-files/small-file-98.txt new file mode 100644 index 0000000000..2647911e47 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-98.txt @@ -0,0 +1 @@ +I am small file 98 diff --git a/tests/benchmarks/many-small-files/small-file-99.txt b/tests/benchmarks/many-small-files/small-file-99.txt new file mode 100644 index 0000000000..81a4ad9493 --- /dev/null +++ b/tests/benchmarks/many-small-files/small-file-99.txt @@ -0,0 +1 @@ +I am small file 99 diff --git a/tests/benchmarks/run-benchmarks.sh b/tests/benchmarks/run-benchmarks.sh index 7542abbfc8..26455665df 100755 --- a/tests/benchmarks/run-benchmarks.sh +++ b/tests/benchmarks/run-benchmarks.sh @@ -136,3 +136,13 @@ for wrap in character never; do cat "$RESULT_DIR/syntax-highlighting-speed-${filename}.md" >> "$REPORT" done done + + +heading "Many small files speed (overhead of metadata)" +hyperfine \ + "$(printf "%q" "$BAT") --no-config --language=txt --style=plain many-small-files/*.txt" \ + --command-name 'bat … --language=txt *.txt' \ + --warmup "$WARMUP_COUNT" \ + --export-markdown "$RESULT_DIR/many-small-files-speed.md" \ + --export-json "$RESULT_DIR/many-small-files-speed.json" +cat "$RESULT_DIR/many-small-files-speed.md" >> "$REPORT" From 1b121d693f5604a01213ab0bdba02877241b0a9e Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Mon, 7 Feb 2022 08:32:09 +0000 Subject: [PATCH 15/15] add changelog entry for header-filesize --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59086f09cc..c5b20fd667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Features +- New style component `header-filesize` to show size of the displayed file in the header. See #1988 (@mdibaiee) + ## Bugfixes ## Other