From 3a9d574770301f874af55b19b39d2c618966f135 Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Wed, 15 May 2024 14:31:25 +0800 Subject: [PATCH 01/67] Add syntax mapping for `/etc/pacman.conf` --- src/syntax_mapping/builtins/linux/50-pacman.toml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/syntax_mapping/builtins/linux/50-pacman.toml b/src/syntax_mapping/builtins/linux/50-pacman.toml index 655118c5..2f4ee71f 100644 --- a/src/syntax_mapping/builtins/linux/50-pacman.toml +++ b/src/syntax_mapping/builtins/linux/50-pacman.toml @@ -1,3 +1,8 @@ [mappings] -# pacman hooks -"INI" = ["/usr/share/libalpm/hooks/*.hook", "/etc/pacman.d/hooks/*.hook"] +"INI" = [ + # config + "/etc/pacman.conf", + # hooks + "/usr/share/libalpm/hooks/*.hook", + "/etc/pacman.d/hooks/*.hook", +] From f82487daf8d24285c6206af49809992a7371ff18 Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Wed, 15 May 2024 14:35:47 +0800 Subject: [PATCH 02/67] Write changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28e56e34..5a7177c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ - Added auto detect syntax for `.jsonc` #2795 (@mxaddict) - Added auto detect syntax for `.aws/{config,credentials}` #2795 (@mxaddict) - Add syntax mapping for Wireguard config #2874 (@cyqsimon) +- Add syntax mapping for `/etc/pacman.conf` #2961 (@cyqsimon) ## Themes From b4fe182960e45d4fd9ebd5ac2c4d2e4b4522b144 Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Mon, 10 Jun 2024 19:58:56 -0700 Subject: [PATCH 03/67] Make EscapeSequenceOffsetsIterator pub, add fns to get indices --- src/vscreen.rs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/vscreen.rs b/src/vscreen.rs index e211c2aa..9e29f9cc 100644 --- a/src/vscreen.rs +++ b/src/vscreen.rs @@ -285,7 +285,7 @@ fn join( /// A range of indices for a raw ANSI escape sequence. #[derive(Debug, PartialEq)] -enum EscapeSequenceOffsets { +pub enum EscapeSequenceOffsets { Text { start: usize, end: usize, @@ -320,6 +320,32 @@ enum EscapeSequenceOffsets { }, } +impl EscapeSequenceOffsets { + /// Returns the byte-index of the first character in the escape sequence. + pub fn index_of_start(&self) -> usize { + use EscapeSequenceOffsets::*; + match self { + Text { start, .. } => *start, + Unknown { start, .. } => *start, + NF { start_sequence, .. } => *start_sequence, + OSC { start_sequence, .. } => *start_sequence, + CSI { start_sequence, .. } => *start_sequence, + } + } + + /// Returns the byte-index past the last character in the escape sequence. + pub fn index_past_end(&self) -> usize { + use EscapeSequenceOffsets::*; + match self { + Text { end, .. } => *end, + Unknown { end, .. } => *end, + NF { end, .. } => *end, + OSC { end, .. } => *end, + CSI { end, .. } => *end, + } + } +} + /// An iterator over the offests of ANSI/VT escape sequences within a string. /// /// ## Example @@ -327,7 +353,7 @@ enum EscapeSequenceOffsets { /// ```ignore /// let iter = EscapeSequenceOffsetsIterator::new("\x1B[33mThis is yellow text.\x1B[m"); /// ``` -struct EscapeSequenceOffsetsIterator<'a> { +pub struct EscapeSequenceOffsetsIterator<'a> { text: &'a str, chars: Peekable>, } From 9c76b728251c05ecace9d9b1a42830b67894039a Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Mon, 10 Jun 2024 20:07:54 -0700 Subject: [PATCH 04/67] Update expand_tabs to use bat's ANSI iterator --- src/preprocessor.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/preprocessor.rs b/src/preprocessor.rs index 3328f3b6..02d1b289 100644 --- a/src/preprocessor.rs +++ b/src/preprocessor.rs @@ -1,17 +1,18 @@ use std::fmt::Write; -use console::AnsiCodeIterator; - -use crate::nonprintable_notation::NonprintableNotation; +use crate::{ + nonprintable_notation::NonprintableNotation, + vscreen::{EscapeSequenceOffsets, EscapeSequenceOffsetsIterator}, +}; /// Expand tabs like an ANSI-enabled expand(1). pub fn expand_tabs(line: &str, width: usize, cursor: &mut usize) -> String { let mut buffer = String::with_capacity(line.len() * 2); - for chunk in AnsiCodeIterator::new(line) { - match chunk { - (text, true) => buffer.push_str(text), - (mut text, false) => { + for seq in EscapeSequenceOffsetsIterator::new(line) { + match seq { + EscapeSequenceOffsets::Text { .. } => { + let mut text = &line[seq.index_of_start()..seq.index_past_end()]; while let Some(index) = text.find('\t') { // Add previous text. if index > 0 { @@ -31,6 +32,10 @@ pub fn expand_tabs(line: &str, width: usize, cursor: &mut usize) -> String { *cursor += text.len(); buffer.push_str(text); } + _ => { + // Copy the ANSI escape sequence. + buffer.push_str(&line[seq.index_of_start()..seq.index_past_end()]) + } } } From 243819ecdcf25339741f9d4640e262dea677f239 Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Sat, 15 Jun 2024 16:12:04 -0700 Subject: [PATCH 05/67] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61af4459..e81c47e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ - Display which theme is the default one in colored output, see #2838 (@sblondon) - Add aarch64-apple-darwin ("Apple Silicon") binary tarballs to releases, see #2967 (@someposer) - Update the Lisp syntax, see #2970 (@ccqpein) +- Use bat's ANSI iterator during tab expansion, see #2998 (@eth-p) ## Syntaxes From c264ecd26b16ebb4f309db03d5a16b1f6e38ca67 Mon Sep 17 00:00:00 2001 From: Tong Zhaoqi <1661610563@qq.com> Date: Mon, 17 Jun 2024 02:16:11 +0800 Subject: [PATCH 06/67] ci: support aarch64 statically-linked binary (#2992) --- .github/workflows/CICD.yml | 1 + CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 831e2f6c..68515f3d 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -163,6 +163,7 @@ jobs: fail-fast: false matrix: job: + - { target: aarch64-unknown-linux-musl , os: ubuntu-20.04, dpkg_arch: arm64, use-cross: true } - { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, dpkg_arch: arm64, use-cross: true } - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, dpkg_arch: armhf, use-cross: true } - { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, dpkg_arch: musl-linux-armhf, use-cross: true } diff --git a/CHANGELOG.md b/CHANGELOG.md index e81c47e2..b7aca166 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ - Add aarch64-apple-darwin ("Apple Silicon") binary tarballs to releases, see #2967 (@someposer) - Update the Lisp syntax, see #2970 (@ccqpein) - Use bat's ANSI iterator during tab expansion, see #2998 (@eth-p) +- Support 'statically linked binary' for aarch64 in 'Release' page, see #2992 (@tzq0301) ## Syntaxes From 70ff93d2386433723acbbe76711d299dfe9dca99 Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Mon, 10 Jun 2024 21:05:20 -0700 Subject: [PATCH 07/67] Add `--strip-ansi` option --- doc/long-help.txt | 4 +++ src/bin/bat/app.rs | 10 ++++++ src/bin/bat/clap_app.rs | 12 +++++++ src/config.rs | 4 +++ src/lib.rs | 1 + src/preprocessor.rs | 31 ++++++++++++++++ src/printer.rs | 20 ++++++++++- tests/integration_tests.rs | 74 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 155 insertions(+), 1 deletion(-) diff --git a/doc/long-help.txt b/doc/long-help.txt index a6ffe962..93f56968 100644 --- a/doc/long-help.txt +++ b/doc/long-help.txt @@ -122,6 +122,10 @@ Options: --squeeze-limit Set the maximum number of consecutive empty lines to be printed. + --strip-ansi + Specify when to strip ANSI escape sequences from the input. Possible values: always, + *never*. + --style Configure which elements (line numbers, file headers, grid borders, Git modifications, ..) to display in addition to the file contents. The argument is a comma-separated list of diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 6fc85321..62ffdd6d 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -7,6 +7,7 @@ use crate::{ clap_app, config::{get_args_from_config_file, get_args_from_env_opts_var, get_args_from_env_vars}, }; +use bat::StripAnsiMode; use clap::ArgMatches; use console::Term; @@ -242,6 +243,15 @@ impl App { 4 }, ), + strip_ansi: match self + .matches + .get_one::("strip-ansi") + .map(|s| s.as_str()) + { + Some("never") => StripAnsiMode::Never, + Some("always") => StripAnsiMode::Always, + _ => unreachable!("other values for --strip-ansi are not allowed"), + }, theme: self .matches .get_one::("theme") diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index b82762b6..32c7c077 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -402,6 +402,18 @@ pub fn build_app(interactive_output: bool) -> Command { .long_help("Set the maximum number of consecutive empty lines to be printed.") .hide_short_help(true) ) + .arg( + Arg::new("strip-ansi") + .long("strip-ansi") + .overrides_with("strip-ansi") + .value_name("when") + .value_parser(["always", "never"]) + .default_value("never") + .hide_default_value(true) + .help("Strip colors from the input (always, *never*)") + .long_help("Specify when to strip ANSI escape sequences from the input. Possible values: always, *never*.") + .hide_short_help(true) + ) .arg( Arg::new("style") .long("style") diff --git a/src/config.rs b/src/config.rs index 0298bb2a..eb7df8ee 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,6 +5,7 @@ use crate::paging::PagingMode; use crate::style::StyleComponents; use crate::syntax_mapping::SyntaxMapping; use crate::wrapping::WrappingMode; +use crate::StripAnsiMode; #[derive(Debug, Clone)] pub enum VisibleLines { @@ -100,6 +101,9 @@ pub struct Config<'a> { /// The maximum number of consecutive empty lines to display pub squeeze_lines: Option, + + // Weather or not to set terminal title when using a pager + pub strip_ansi: StripAnsiMode, } #[cfg(all(feature = "minimal-application", feature = "paging"))] diff --git a/src/lib.rs b/src/lib.rs index 0296ad32..23c4a800 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,6 +53,7 @@ mod vscreen; pub(crate) mod wrapping; pub use nonprintable_notation::NonprintableNotation; +pub use preprocessor::StripAnsiMode; pub use pretty_printer::{Input, PrettyPrinter, Syntax}; pub use syntax_mapping::{MappingTarget, SyntaxMapping}; pub use wrapping::WrappingMode; diff --git a/src/preprocessor.rs b/src/preprocessor.rs index 02d1b289..707946f9 100644 --- a/src/preprocessor.rs +++ b/src/preprocessor.rs @@ -136,6 +136,26 @@ pub fn replace_nonprintable( output } +/// Strips ANSI escape sequences from the input. +pub fn strip_ansi(line: &str) -> String { + let mut buffer = String::with_capacity(line.len()); + + for seq in EscapeSequenceOffsetsIterator::new(line) { + if let EscapeSequenceOffsets::Text { .. } = seq { + buffer.push_str(&line[seq.index_of_start()..seq.index_past_end()]); + } + } + + buffer +} + +#[derive(Debug, PartialEq, Clone, Copy, Default)] +pub enum StripAnsiMode { + #[default] + Never, + Always, +} + #[test] fn test_try_parse_utf8_char() { assert_eq!(try_parse_utf8_char(&[0x20]), Some((' ', 1))); @@ -179,3 +199,14 @@ fn test_try_parse_utf8_char() { assert_eq!(try_parse_utf8_char(&[0xef, 0x20]), None); assert_eq!(try_parse_utf8_char(&[0xf0, 0xf0]), None); } + +#[test] +fn test_strip_ansi() { + // The sequence detection is covered by the tests in the vscreen module. + assert_eq!(strip_ansi("no ansi"), "no ansi"); + assert_eq!(strip_ansi("\x1B[33mone"), "one"); + assert_eq!( + strip_ansi("\x1B]1\x07multiple\x1B[J sequences"), + "multiple sequences" + ); +} diff --git a/src/printer.rs b/src/printer.rs index 282f0fe1..d76e6e0a 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -29,11 +29,13 @@ use crate::diff::LineChanges; use crate::error::*; use crate::input::OpenedInput; use crate::line_range::RangeCheckResult; +use crate::preprocessor::strip_ansi; use crate::preprocessor::{expand_tabs, replace_nonprintable}; use crate::style::StyleComponent; use crate::terminal::{as_terminal_escaped, to_ansi_color}; use crate::vscreen::{AnsiStyle, EscapeSequence, EscapeSequenceIterator}; use crate::wrapping::WrappingMode; +use crate::StripAnsiMode; const ANSI_UNDERLINE_ENABLE: EscapeSequence = EscapeSequence::CSI { raw_sequence: "\x1B[4m", @@ -207,6 +209,7 @@ pub(crate) struct InteractivePrinter<'a> { highlighter_from_set: Option>, background_color_highlight: Option, consecutive_empty_lines: usize, + strip_ansi: bool, } impl<'a> InteractivePrinter<'a> { @@ -281,6 +284,13 @@ impl<'a> InteractivePrinter<'a> { Some(HighlighterFromSet::new(syntax_in_set, theme)) }; + // Determine when to strip ANSI sequences + let strip_ansi = match config.strip_ansi { + _ if config.show_nonprintable => false, + StripAnsiMode::Always => true, + _ => false, + }; + Ok(InteractivePrinter { panel_width, colors, @@ -293,6 +303,7 @@ impl<'a> InteractivePrinter<'a> { highlighter_from_set, background_color_highlight, consecutive_empty_lines: 0, + strip_ansi, }) } @@ -573,7 +584,7 @@ impl<'a> Printer for InteractivePrinter<'a> { ) .into() } else { - match self.content_type { + let mut line = match self.content_type { Some(ContentType::BINARY) | None => { return Ok(()); } @@ -590,7 +601,14 @@ impl<'a> Printer for InteractivePrinter<'a> { line } } + }; + + // If ANSI escape sequences are supposed to be stripped, do it before syntax highlighting. + if self.strip_ansi { + line = strip_ansi(&line).into() } + + line }; let regions = self.highlight_regions_for_line(&line)?; diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 0285ac26..bc86cb9b 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -2666,3 +2666,77 @@ fn highlighting_independant_from_map_syntax_case() { .stdout(expected) .stderr(""); } + +#[test] +fn strip_ansi_always_strips_ansi() { + bat() + .arg("--style=plain") + .arg("--decorations=always") + .arg("--color=never") + .arg("--strip-ansi=always") + .write_stdin("\x1B[33mYellow\x1B[m") + .assert() + .success() + .stdout("Yellow"); +} + +#[test] +fn strip_ansi_never_does_not_strip_ansi() { + let output = String::from_utf8( + bat() + .arg("--style=plain") + .arg("--decorations=always") + .arg("--color=never") + .arg("--strip-ansi=never") + .write_stdin("\x1B[33mYellow\x1B[m") + .assert() + .success() + .get_output() + .stdout + .clone(), + ) + .expect("valid utf8"); + + assert!(output.contains("\x1B[33mYellow")) +} + +#[test] +fn strip_ansi_does_not_affect_simple_printer() { + let output = String::from_utf8( + bat() + .arg("--style=plain") + .arg("--decorations=never") + .arg("--color=never") + .arg("--strip-ansi=always") + .write_stdin("\x1B[33mYellow\x1B[m") + .assert() + .success() + .get_output() + .stdout + .clone(), + ) + .expect("valid utf8"); + + assert!(output.contains("\x1B[33mYellow")) +} + +#[test] +fn strip_ansi_does_not_strip_when_show_nonprintable() { + let output = String::from_utf8( + bat() + .arg("--style=plain") + .arg("--decorations=never") + .arg("--color=always") + .arg("--strip-ansi=always") + .arg("--show-nonprintable") + .write_stdin("\x1B[33mY") + .assert() + .success() + .get_output() + .stdout + .clone(), + ) + .expect("valid utf8"); + + assert!(output.contains("␛")) +} From 9e8176b1c69235b91c14aaa56c5862ed7dff3a9b Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Mon, 10 Jun 2024 21:17:28 -0700 Subject: [PATCH 08/67] Add `--strip-ansi=auto` option When using `auto`, escape sequences will be stripped unless printing plain text. --- doc/long-help.txt | 5 +-- src/bin/bat/app.rs | 1 + src/bin/bat/clap_app.rs | 8 +++-- src/preprocessor.rs | 1 + src/printer.rs | 40 +++++++++++++++------- tests/integration_tests.rs | 70 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 18 deletions(-) diff --git a/doc/long-help.txt b/doc/long-help.txt index 93f56968..d9cdce39 100644 --- a/doc/long-help.txt +++ b/doc/long-help.txt @@ -123,8 +123,9 @@ Options: Set the maximum number of consecutive empty lines to be printed. --strip-ansi - Specify when to strip ANSI escape sequences from the input. Possible values: always, - *never*. + Specify when to strip ANSI escape sequences from the input. The automatic mode will remove + escape sequences unless the syntax highlighting language is plain text. Possible values: + auto, always, *never*. --style Configure which elements (line numbers, file headers, grid borders, Git modifications, ..) diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 62ffdd6d..0d2600b2 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -250,6 +250,7 @@ impl App { { Some("never") => StripAnsiMode::Never, Some("always") => StripAnsiMode::Always, + Some("auto") => StripAnsiMode::Auto, _ => unreachable!("other values for --strip-ansi are not allowed"), }, theme: self diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 32c7c077..e70b1a5b 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -407,11 +407,13 @@ pub fn build_app(interactive_output: bool) -> Command { .long("strip-ansi") .overrides_with("strip-ansi") .value_name("when") - .value_parser(["always", "never"]) + .value_parser(["auto", "always", "never"]) .default_value("never") .hide_default_value(true) - .help("Strip colors from the input (always, *never*)") - .long_help("Specify when to strip ANSI escape sequences from the input. Possible values: always, *never*.") + .help("Strip colors from the input (auto, always, *never*)") + .long_help("Specify when to strip ANSI escape sequences from the input. \ + The automatic mode will remove escape sequences unless the syntax highlighting \ + language is plain text. Possible values: auto, always, *never*.") .hide_short_help(true) ) .arg( diff --git a/src/preprocessor.rs b/src/preprocessor.rs index 707946f9..dc2aa66e 100644 --- a/src/preprocessor.rs +++ b/src/preprocessor.rs @@ -154,6 +154,7 @@ pub enum StripAnsiMode { #[default] Never, Always, + Auto, } #[test] diff --git a/src/printer.rs b/src/printer.rs index d76e6e0a..e9bea3fd 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -268,26 +268,40 @@ impl<'a> InteractivePrinter<'a> { .content_type .map_or(false, |c| c.is_binary() && !config.show_nonprintable); - let highlighter_from_set = if is_printing_binary || !config.colored_output { - None - } else { - // Determine the type of syntax for highlighting - let syntax_in_set = - match assets.get_syntax(config.language, input, &config.syntax_mapping) { - Ok(syntax_in_set) => syntax_in_set, - Err(Error::UndetectedSyntax(_)) => assets - .find_syntax_by_name("Plain Text")? - .expect("A plain text syntax is available"), - Err(e) => return Err(e), - }; + let needs_to_match_syntax = !is_printing_binary + && (config.colored_output || config.strip_ansi == StripAnsiMode::Auto); - Some(HighlighterFromSet::new(syntax_in_set, theme)) + let (is_plain_text, highlighter_from_set) = if needs_to_match_syntax { + // Determine the type of syntax for highlighting + const PLAIN_TEXT_SYNTAX: &str = "Plain Text"; + match assets.get_syntax(config.language, input, &config.syntax_mapping) { + Ok(syntax_in_set) => ( + syntax_in_set.syntax.name == PLAIN_TEXT_SYNTAX, + Some(HighlighterFromSet::new(syntax_in_set, theme)), + ), + + Err(Error::UndetectedSyntax(_)) => ( + true, + Some( + assets + .find_syntax_by_name(PLAIN_TEXT_SYNTAX)? + .map(|s| HighlighterFromSet::new(s, theme)) + .expect("A plain text syntax is available"), + ), + ), + + Err(e) => return Err(e), + } + } else { + (false, None) }; // Determine when to strip ANSI sequences let strip_ansi = match config.strip_ansi { _ if config.show_nonprintable => false, StripAnsiMode::Always => true, + StripAnsiMode::Auto if is_plain_text => false, // Plain text may already contain escape sequences. + StripAnsiMode::Auto => true, _ => false, }; diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index bc86cb9b..d6009361 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -2740,3 +2740,73 @@ fn strip_ansi_does_not_strip_when_show_nonprintable() { assert!(output.contains("␛")) } + +#[test] +fn strip_ansi_auto_strips_ansi_when_detected_syntax_by_filename() { + bat() + .arg("--style=plain") + .arg("--decorations=always") + .arg("--color=never") + .arg("--strip-ansi=auto") + .arg("--file-name=test.rs") + .write_stdin("fn \x1B[33mYellow\x1B[m() -> () {}") + .assert() + .success() + .stdout("fn Yellow() -> () {}"); +} + +#[test] +fn strip_ansi_auto_strips_ansi_when_provided_syntax_by_option() { + bat() + .arg("--style=plain") + .arg("--decorations=always") + .arg("--color=never") + .arg("--strip-ansi=auto") + .arg("--language=rust") + .write_stdin("fn \x1B[33mYellow\x1B[m() -> () {}") + .assert() + .success() + .stdout("fn Yellow() -> () {}"); +} + +#[test] +fn strip_ansi_auto_does_not_strip_when_plain_text_by_filename() { + let output = String::from_utf8( + bat() + .arg("--style=plain") + .arg("--decorations=always") + .arg("--color=never") + .arg("--strip-ansi=auto") + .arg("--file-name=ansi.txt") + .write_stdin("\x1B[33mYellow\x1B[m") + .assert() + .success() + .get_output() + .stdout + .clone(), + ) + .expect("valid utf8"); + + assert!(output.contains("\x1B[33mYellow")) +} + +#[test] +fn strip_ansi_auto_does_not_strip_ansi_when_plain_text_by_option() { + let output = String::from_utf8( + bat() + .arg("--style=plain") + .arg("--decorations=always") + .arg("--color=never") + .arg("--strip-ansi=auto") + .arg("--language=txt") + .write_stdin("\x1B[33mYellow\x1B[m") + .assert() + .success() + .get_output() + .stdout + .clone(), + ) + .expect("valid utf8"); + + assert!(output.contains("\x1B[33mYellow")) +} From 3f22311ec8812e83bc9c26e22501acf3b92337bf Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Sat, 15 Jun 2024 16:27:44 -0700 Subject: [PATCH 09/67] Add ANSI stripping to bat-as-a-library --- src/pretty_printer.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs index c6203aa9..eb123ea3 100644 --- a/src/pretty_printer.rs +++ b/src/pretty_printer.rs @@ -11,7 +11,7 @@ use crate::{ input, line_range::{HighlightedLineRanges, LineRange, LineRanges}, style::StyleComponent, - SyntaxMapping, WrappingMode, + StripAnsiMode, SyntaxMapping, WrappingMode, }; #[cfg(feature = "paging")] @@ -182,6 +182,15 @@ impl<'a> PrettyPrinter<'a> { self } + /// Whether to remove ANSI escape sequences from the input (default: never) + /// + /// If `Auto` is used, escape sequences will only be removed when the input + /// is not plain text. + pub fn strip_ansi(&mut self, mode: StripAnsiMode) -> &mut Self { + self.config.strip_ansi = mode; + self + } + /// Text wrapping mode (default: do not wrap) pub fn wrapping_mode(&mut self, mode: WrappingMode) -> &mut Self { self.config.wrapping_mode = mode; From 3f8d62e7d659b4c86da9d3e74d2fc65388804e90 Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Sat, 15 Jun 2024 16:36:07 -0700 Subject: [PATCH 10/67] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7aca166..7e361ddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - `bat --squeeze-limit` to set the maximum number of empty consecutive when using `--squeeze-blank`, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815) - `PrettyPrinter::squeeze_empty_lines` to support line squeezing for bat as a library, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815) - Syntax highlighting for JavaScript files that start with `#!/usr/bin/env bun` #2913 (@sharunkumar) +- `bat --strip-ansi={never,always,auto}` to remove ANSI escape sequences from bat's input, see #2999 (@eth-p) ## Bugfixes From 90dfa7f18d72c7236199f0309941a9c59f061fe2 Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Sat, 15 Jun 2024 17:12:02 -0700 Subject: [PATCH 11/67] Update README.md to mention `--strip-ansi` --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 57baf2b0..0abd9bbd 100644 --- a/README.md +++ b/README.md @@ -759,9 +759,14 @@ bat() { If an input file contains color codes or other ANSI escape sequences or control characters, `bat` will have problems performing syntax highlighting and text wrapping, and thus the output can become garbled. -When displaying such files it is recommended to disable both syntax highlighting and wrapping by + +If your version of `bat` supports the `--strip-ansi=auto` option, it can be used to remove such sequences +before syntax highlighting. Alternatively, you may disable both syntax highlighting and wrapping by passing the `--color=never --wrap=never` options to `bat`. +> [!NOTE] +> The `auto` option of `--strip-ansi` avoids removing escape sequences when the syntax is plain text. + ### Terminals & colors `bat` handles terminals *with* and *without* truecolor support. However, the colors in most syntax From b265b20721331d898548374099875a085f239eee Mon Sep 17 00:00:00 2001 From: Bryan Honof Date: Wed, 12 Jun 2024 15:23:36 +0200 Subject: [PATCH 12/67] Add flox install --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 0abd9bbd..9391f1c0 100644 --- a/README.md +++ b/README.md @@ -373,6 +373,14 @@ You can install `bat` using the [nix package manager](https://nixos.org/nix): nix-env -i bat ``` +### Via flox + +You can install `bat` using [Flox](https://flox.dev) + +```bash +flox install bat +``` + ### On openSUSE You can install `bat` with zypper: From cee5584daf0dab8bde104093c589e2ad3d33ee88 Mon Sep 17 00:00:00 2001 From: Driss Boumlik Date: Fri, 28 Jun 2024 15:05:21 +0100 Subject: [PATCH 13/67] Fix cmder link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9391f1c0..1e42e501 100644 --- a/README.md +++ b/README.md @@ -737,7 +737,7 @@ your `PATH` or [define an environment variable](#using-a-different-pager). The [ Windows 10 natively supports colors in both `conhost.exe` (Command Prompt) and PowerShell since [v1511](https://en.wikipedia.org/wiki/Windows_10_version_history#Version_1511_(November_Update)), as well as in newer versions of bash. On earlier versions of Windows, you can use -[Cmder](http://cmder.net/), which includes [ConEmu](https://conemu.github.io/). +[Cmder](http://cmder.app/), which includes [ConEmu](https://conemu.github.io/). **Note:** Old versions of `less` do not correctly interpret colors on Windows. To fix this, you can add the optional Unix tools to your PATH when installing Git. If you don’t have any other pagers installed, you can disable paging entirely by passing `--paging=never` or by setting `BAT_PAGER` to an empty string. From b9c74ab859e420ef849ce77a49b843977663a6ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 02:29:47 +0000 Subject: [PATCH 14/67] Bump walkdir from 2.4.0 to 2.5.0 (#3018) Bumps [walkdir](https://github.com/BurntSushi/walkdir) from 2.4.0 to 2.5.0. - [Commits](https://github.com/BurntSushi/walkdir/compare/2.4.0...2.5.0) --- updated-dependencies: - dependency-name: walkdir dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 792f5c49..05899e00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1493,9 +1493,9 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", diff --git a/Cargo.toml b/Cargo.toml index 8894da5c..2092f9ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,7 +63,7 @@ bugreport = { version = "0.5.0", optional = true } etcetera = { version = "0.8.0", optional = true } grep-cli = { version = "0.1.10", optional = true } regex = { version = "1.10.2", optional = true } -walkdir = { version = "2.4", optional = true } +walkdir = { version = "2.5", optional = true } bytesize = { version = "1.3.0" } encoding_rs = "0.8.33" os_str_bytes = { version = "~7.0", optional = true } @@ -110,7 +110,7 @@ serde = "1.0" serde_derive = "1.0" serde_with = { version = "3.8.1", default-features = false, features = ["macros"] } toml = { version = "0.8.9", features = ["preserve_order"] } -walkdir = "2.4" +walkdir = "2.5" [build-dependencies.clap] version = "4.4.12" From 609005a2254f4a96d8ae70adebae557c1761e0f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 02:51:38 +0000 Subject: [PATCH 15/67] Bump encoding_rs from 0.8.33 to 0.8.34 (#3020) Bumps [encoding_rs](https://github.com/hsivonen/encoding_rs) from 0.8.33 to 0.8.34. - [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.33...v0.8.34) --- updated-dependencies: - dependency-name: encoding_rs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 05899e00..f7c1617f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -416,9 +416,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] diff --git a/Cargo.toml b/Cargo.toml index 2092f9ad..6dd814f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,7 @@ grep-cli = { version = "0.1.10", optional = true } regex = { version = "1.10.2", optional = true } walkdir = { version = "2.5", optional = true } bytesize = { version = "1.3.0" } -encoding_rs = "0.8.33" +encoding_rs = "0.8.34" os_str_bytes = { version = "~7.0", optional = true } run_script = { version = "^0.10.1", optional = true} From 7873b473e83f83e635e3ebceee2a840c1f162c95 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 03:16:35 +0000 Subject: [PATCH 16/67] Bump unicode-width from 0.1.11 to 0.1.13 (#3019) Bumps [unicode-width](https://github.com/unicode-rs/unicode-width) from 0.1.11 to 0.1.13. - [Commits](https://github.com/unicode-rs/unicode-width/compare/v0.1.11...v0.1.13) --- updated-dependencies: - dependency-name: unicode-width dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7c1617f..0ff38246 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1449,9 +1449,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unsafe-libyaml" diff --git a/Cargo.toml b/Cargo.toml index 6dd814f2..ea940840 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ thiserror = "1.0" wild = { version = "2.2", optional = true } content_inspector = "0.2.4" shell-words = { version = "1.1.0", optional = true } -unicode-width = "0.1.11" +unicode-width = "0.1.13" globset = "0.4" serde = "1.0" serde_derive = "1.0" From 6fc58821a53e8dff0690a1f6a144cee6d4676b71 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 03:34:46 +0000 Subject: [PATCH 17/67] Bump anyhow from 1.0.78 to 1.0.86 (#3021) Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.78 to 1.0.86. - [Release notes](https://github.com/dtolnay/anyhow/releases) - [Commits](https://github.com/dtolnay/anyhow/compare/1.0.78...1.0.86) --- updated-dependencies: - dependency-name: anyhow dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ff38246..5fc3e1fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.78" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca87830a3e3fb156dc96cfbd31cb620265dd053be734723f22b760d6cc3c3051" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "assert_cmd" diff --git a/Cargo.toml b/Cargo.toml index ea940840..6170905a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -101,7 +101,7 @@ serde = { version = "1.0", features = ["derive"] } nix = { version = "0.26.4", default-features = false, features = ["term"] } [build-dependencies] -anyhow = "1.0.78" +anyhow = "1.0.86" indexmap = { version = "2.2.6", features = ["serde"] } itertools = "0.13.0" once_cell = "1.18" From de697f771775fd91d2352640b60429f124b11818 Mon Sep 17 00:00:00 2001 From: Brenton Bostick Date: Wed, 17 Jul 2024 15:46:38 -0400 Subject: [PATCH 18/67] add CFML syntax --- .gitmodules | 3 ++ assets/syntaxes/02_Extra/CFML | 1 + tests/syntax-tests/highlighted/CFML/test.cfml | 54 +++++++++++++++++++ tests/syntax-tests/source/CFML/test.cfml | 54 +++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 160000 assets/syntaxes/02_Extra/CFML create mode 100644 tests/syntax-tests/highlighted/CFML/test.cfml create mode 100644 tests/syntax-tests/source/CFML/test.cfml diff --git a/.gitmodules b/.gitmodules index 7c8a7724..fe159da8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -260,3 +260,6 @@ [submodule "assets/syntaxes/02_Extra/vscode-wgsl"] path = assets/syntaxes/02_Extra/vscode-wgsl url = https://github.com/PolyMeilex/vscode-wgsl.git +[submodule "assets/syntaxes/02_Extra/CFML"] + path = assets/syntaxes/02_Extra/CFML + url = https://github.com/jcberquist/sublimetext-cfml.git diff --git a/assets/syntaxes/02_Extra/CFML b/assets/syntaxes/02_Extra/CFML new file mode 160000 index 00000000..b91c44a3 --- /dev/null +++ b/assets/syntaxes/02_Extra/CFML @@ -0,0 +1 @@ +Subproject commit b91c44a32e251c20c6359a8d9232287e1b408e6c diff --git a/tests/syntax-tests/highlighted/CFML/test.cfml b/tests/syntax-tests/highlighted/CFML/test.cfml new file mode 100644 index 00000000..4aa8ecdc --- /dev/null +++ b/tests/syntax-tests/highlighted/CFML/test.cfml @@ -0,0 +1,54 @@ +<head>  +<title>Add New Employees  +  +<body>  +<h1>Add New Employees  +  +  +<cfparam name="Form.firstname" default="">  +<cfparam name="Form.lastname" default="">  +<cfparam name="Form.email" default="">  +<cfparam name="Form.phone" default="">  +<cfparam name="Form.department" default="">  +  +<cfif #Form.firstname# eq "">  +<p>Please fill out the form.  +<cfelse>  +<cfoutput>  +<cfscript>  +employee=StructNew();  +employee.firstname = Form.firstname;  +employee.lastname = Form.lastname;  +employee.email = Form.email;  +employee.phone = Form.phone;  +employee.department = Form.department;  +  +  +First name is #StructFind(employee, "firstname")#<br>  +Last name is #StructFind(employee, "lastname")#<br>  +EMail is #StructFind(employee, "email")#<br>  +Phone is #StructFind(employee, "phone")#<br>  +Department is #StructFind(employee, "department")#<br>  +  +  +<cf_addemployee empinfo="#employee#">  +  +  +<hr>  +<form action="newemployee.cfm" method="Post">  +First Name:&nbsp;  +<input name="firstname" type="text" hspace="30" maxlength="30"><br>  +Last Name:&nbsp;  +<input name="lastname" type="text" hspace="30" maxlength="30"><br>  +EMail:&nbsp;  +<input name="email" type="text" hspace="30" maxlength="30"><br>  +Phone:&nbsp;  +<input name="phone" type="text" hspace="20" maxlength="20"><br>  +Department:&nbsp;  +<input name="department" type="text" hspace="30" maxlength="30"><br>  +<input type="Submit" value="OK">  +  +<br>  +  + diff --git a/tests/syntax-tests/source/CFML/test.cfml b/tests/syntax-tests/source/CFML/test.cfml new file mode 100644 index 00000000..f119af76 --- /dev/null +++ b/tests/syntax-tests/source/CFML/test.cfml @@ -0,0 +1,54 @@ + +Add New Employees + + +

Add New Employees

+ + + + + + + + + +

Please fill out the form.

+ + + +employee=StructNew(); +employee.firstname = Form.firstname; +employee.lastname = Form.lastname; +employee.email = Form.email; +employee.phone = Form.phone; +employee.department = Form.department; + + +First name is #StructFind(employee, "firstname")#
+Last name is #StructFind(employee, "lastname")#
+EMail is #StructFind(employee, "email")#
+Phone is #StructFind(employee, "phone")#
+Department is #StructFind(employee, "department")#
+
+ + +
+ +
+
+First Name:  +
+Last Name:  +
+EMail:  +
+Phone:  +
+Department:  +
+ +
+
+ + From 50b01ea8dab019641f1233241d919e002ceab272 Mon Sep 17 00:00:00 2001 From: Brenton Bostick Date: Wed, 17 Jul 2024 16:17:41 -0400 Subject: [PATCH 19/67] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e361ddb..fb7231b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ - Added auto detect syntax for `.jsonc` #2795 (@mxaddict) - Added auto detect syntax for `.aws/{config,credentials}` #2795 (@mxaddict) - Add syntax mapping for Wireguard config #2874 (@cyqsimon) +- Add support for [CFML](https://www.adobe.com/products/coldfusion-family.html), see #3031 (@brenton-at-pieces) ## Themes From ff71e32c0f1cf70a404329e64a964acee1c084cc Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sun, 21 Jul 2024 23:09:49 +0200 Subject: [PATCH 20/67] Update the Protobuf sobmodule (fixes #2542) --- CHANGELOG.md | 1 + assets/syntaxes/02_Extra/Protobuf | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e361ddb..8bb7a579 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ - Added auto detect syntax for `.jsonc` #2795 (@mxaddict) - Added auto detect syntax for `.aws/{config,credentials}` #2795 (@mxaddict) - Add syntax mapping for Wireguard config #2874 (@cyqsimon) +- Associate `.textproto` files with `ProtoBuf` syntax, see #3038 (@vorburger). ## Themes diff --git a/assets/syntaxes/02_Extra/Protobuf b/assets/syntaxes/02_Extra/Protobuf index 726e21d7..13653315 160000 --- a/assets/syntaxes/02_Extra/Protobuf +++ b/assets/syntaxes/02_Extra/Protobuf @@ -1 +1 @@ -Subproject commit 726e21d74dac23cbb036f2fbbd626decdc954060 +Subproject commit 1365331580b0e4bb86f74d0c599dccc87e7bdacb From c34bdb5e66015e65ceecaa637b9e7316a5db92c0 Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:10:17 +0800 Subject: [PATCH 21/67] Bump time to 0.3.36 (fixes #3043) --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5fc3e1fd..c49ff655 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1347,9 +1347,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -1368,9 +1368,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", From 1a11ba11e32ab4cdeee3fd9a3afa19a69d210514 Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:18:16 +0800 Subject: [PATCH 22/67] Write changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bb7a579..27a2d806 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Fix handling of inputs with OSC ANSI escape sequences, see #2541 and #2544 (@eth-p) - Fix handling of inputs with combined ANSI color and attribute sequences, see #2185 and #2856 (@eth-p) - Fix panel width when line 10000 wraps, see #2854 (@eth-p) +- Fix compile issue of `time` dependency caused by standard library regression #3045 (@cyqsimon) ## Other From 7bd6cdbebc232585e09bea563c5ee0cdaa50f0f9 Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:37:48 +0800 Subject: [PATCH 23/67] Add syntax mapping for kubernetes config files --- src/syntax_mapping/builtins/linux/50-kubernetes.toml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/syntax_mapping/builtins/linux/50-kubernetes.toml diff --git a/src/syntax_mapping/builtins/linux/50-kubernetes.toml b/src/syntax_mapping/builtins/linux/50-kubernetes.toml new file mode 100644 index 00000000..6a81a35a --- /dev/null +++ b/src/syntax_mapping/builtins/linux/50-kubernetes.toml @@ -0,0 +1,2 @@ +[mappings] +"YAML" = ["/etc/kubernetes/*.conf"] From 319b8868fc93c1fd026a67b58c4192fa535e015c Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Fri, 26 Jul 2024 23:39:27 +0800 Subject: [PATCH 24/67] Write changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27a2d806..a4a6ed16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ - Added auto detect syntax for `.aws/{config,credentials}` #2795 (@mxaddict) - Add syntax mapping for Wireguard config #2874 (@cyqsimon) - Associate `.textproto` files with `ProtoBuf` syntax, see #3038 (@vorburger). +- Add syntax mapping for kubernetes config files #3049 (@cyqsimon) ## Themes From 23fd20048272922c87ea4759f5b7a52ceb8e6d1a Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sun, 21 Jul 2024 22:56:16 +0200 Subject: [PATCH 25/67] Associate JSON-LD `.jsonld` files with `json` syntax (fixes #3036) Use PR instead of Issue # number in CHANGELOG. Clean up (unify) CHANGELOG. --- CHANGELOG.md | 11 ++++++----- src/syntax_mapping/builtins/common/50-json.toml | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36dd079b..aa4c8de0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,11 +49,12 @@ - Upgrade JQ syntax, see #2820 (@dependabot[bot]) - Add syntax mapping for quadman quadlets #2866 (@cyqsimon) - Map containers .conf files to TOML syntax #2867 (@cyqsimon) -- Associate `xsh` files with `xonsh` syntax that is Python, see #2840 (@anki-code). -- Added auto detect syntax for `.jsonc` #2795 (@mxaddict) -- Added auto detect syntax for `.aws/{config,credentials}` #2795 (@mxaddict) -- Add syntax mapping for Wireguard config #2874 (@cyqsimon) -- Associate `.textproto` files with `ProtoBuf` syntax, see #3038 (@vorburger). +- Associate `.xsh` files with `xonsh` syntax that is Python, see #2840 (@anki-code) +- Associate JSON with Comments `.jsonc` with `json` syntax, see #2795 (@mxaddict) +- Associate JSON-LD `.jsonld` files with `json` syntax, see #3037 (@vorburger) +- Associate `.textproto` files with `ProtoBuf` syntax, see #3038 (@vorburger) +- Associate `.aws/{config,credentials}`, see #2795 (@mxaddict) +- Associate Wireguard config `/etc/wireguard/*.conf`, see #2874 (@cyqsimon) - Add support for [CFML](https://www.adobe.com/products/coldfusion-family.html), see #3031 (@brenton-at-pieces) ## Themes diff --git a/src/syntax_mapping/builtins/common/50-json.toml b/src/syntax_mapping/builtins/common/50-json.toml index e604868a..7d33b6fe 100644 --- a/src/syntax_mapping/builtins/common/50-json.toml +++ b/src/syntax_mapping/builtins/common/50-json.toml @@ -1,3 +1,3 @@ # JSON Lines is a simple variation of JSON #2535 [mappings] -"JSON" = ["*.jsonl", "*.jsonc"] +"JSON" = ["*.jsonl", "*.jsonc", "*.jsonld"] From 44ca1e7df15a514ce9afba5bbc2b103042b369b5 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sun, 9 Jun 2024 20:24:00 +0900 Subject: [PATCH 26/67] Add options present in --help to the man page --- assets/manual/bat.1.in | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/assets/manual/bat.1.in b/assets/manual/bat.1.in index b85520da..6d952814 100644 --- a/assets/manual/bat.1.in +++ b/assets/manual/bat.1.in @@ -87,6 +87,10 @@ Set the tab width to T spaces. Use a width of 0 to pass tabs through directly Specify the text\-wrapping mode (*auto*, never, character). The '\-\-terminal\-width' option can be used in addition to control the output width. .HP +\fB\-S\fR, \fB\-\-chop\-long\-lines\fR +.IP +Truncate all lines longer than screen width. Alias for '\-\-wrap=never'. +.HP \fB\-\-terminal\-width\fR .IP Explicitly set the width of the terminal instead of determining it automatically. If @@ -141,6 +145,11 @@ use -m '*.build:Python'. To highlight files named '.myignore' with the Git Ignor syntax, use -m '.myignore:Git Ignore'. Note that the right-hand side is the *name* of the syntax, not a file extension. .HP +\fB\-\-ignored\-suffix\fR +.IP +Ignore extension. For example: 'bat \-\-ignored-suffix ".dev" my_file.json.dev' +will use JSON syntax, and ignore '.dev' +.HP \fB\-\-theme\fR .IP Set the theme for syntax highlighting. Use '\-\-list\-themes' to see all available themes. @@ -151,6 +160,14 @@ export the BAT_THEME environment variable (e.g.: export BAT_THEME="..."). .IP Display a list of supported themes for syntax highlighting. .HP +\fB\-s\fR, \fB\-\-squeeze\-blank\fR +.IP +Squeeze consecutive empty lines into a single empty line. +.HP +\fB\-\-squeeze\-limit\fR +.IP +Set the maximum number of consecutive empty lines to be printed. +.HP \fB\-\-style\fR .IP Configure which elements (line numbers, file headers, grid borders, Git modifications, @@ -184,6 +201,18 @@ Display a list of supported languages for syntax highlighting. This option exists for POSIX\-compliance reasons ('u' is for 'unbuffered'). The output is always unbuffered \- this option is simply ignored. .HP +\fB\-\-diagnostic\fR +.IP +Show diagnostic information for bug reports. +.HP +\fB\-\-acknowledgements\fR +.IP +Show acknowledgements. +.HP +\fB\-\-set\-terminal\-title\fR +.IP +Sets terminal title to filenames when using a pager. +.HP \fB\-h\fR, \fB\-\-help\fR .IP Print this help message. From 43a77a42f81de49b1bce1525140ef1fdd842f961 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sun, 9 Jun 2024 20:40:56 +0900 Subject: [PATCH 27/67] Add options present in --help to Bash completion --- assets/completions/bat.bash.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/assets/completions/bat.bash.in b/assets/completions/bat.bash.in index de8651a8..3ae993c3 100644 --- a/assets/completions/bat.bash.in +++ b/assets/completions/bat.bash.in @@ -76,6 +76,7 @@ _bat() { -m | --map-syntax | \ --ignored-suffix | \ --list-themes | \ + --squeeze-limit | \ --line-range | \ -L | --list-languages | \ --lessopen | \ @@ -157,6 +158,7 @@ _bat() { --diff-context --tabs --wrap + --chop-long-lines --terminal-width --number --color @@ -169,12 +171,15 @@ _bat() { --ignored-suffix --theme --list-themes + --squeeze-blank + --squeeze-limit --style --line-range --list-languages --lessopen --diagnostic --acknowledgements + --set-terminal-title --help --version --cache-dir From 83a15ac05fd60327984a785375dab8d9e7453883 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Mon, 10 Jun 2024 07:48:23 +0900 Subject: [PATCH 28/67] Add --cache-dir to Fish completion --- assets/completions/bat.fish.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/completions/bat.fish.in b/assets/completions/bat.fish.in index d86ebfe6..788f71b0 100644 --- a/assets/completions/bat.fish.in +++ b/assets/completions/bat.fish.in @@ -133,6 +133,8 @@ set -l tabs_opts ' complete -c $bat -l acknowledgements -d "Print acknowledgements" -n __fish_is_first_arg +complete -c $bat -l cache-dir -f -d "Show bat's cache directory" -n __fish_is_first_arg + complete -c $bat -l color -x -a "$color_opts" -d "When to use colored output" -n __bat_no_excl_args complete -c $bat -l config-dir -f -d "Display location of configuration directory" -n __fish_is_first_arg From b1cdc06430a4c99e09d04870cda01a98799917f5 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Mon, 10 Jun 2024 07:52:42 +0900 Subject: [PATCH 29/67] Add --no-* options to Bash/Zsh completions --- assets/completions/bat.bash.in | 3 +++ assets/completions/bat.zsh.in | 1 + 2 files changed, 4 insertions(+) diff --git a/assets/completions/bat.bash.in b/assets/completions/bat.bash.in index 3ae993c3..f314bb25 100644 --- a/assets/completions/bat.bash.in +++ b/assets/completions/bat.bash.in @@ -186,6 +186,9 @@ _bat() { --config-dir --config-file --generate-config-file + --no-config + --no-custom-assets + --no-lessopen " -- "$cur")) return 0 fi diff --git a/assets/completions/bat.zsh.in b/assets/completions/bat.zsh.in index 69caceed..7d03abb3 100644 --- a/assets/completions/bat.zsh.in +++ b/assets/completions/bat.zsh.in @@ -48,6 +48,7 @@ _{{PROJECT_EXECUTABLE}}_main() { default auto full plain changes header header-filename header-filesize grid rule numbers snip' \*{-r+,--line-range=}'[only print the specified line range]:start\:end' '(* -)'{-L,--list-languages}'[display all supported languages]' + -P'[disable paging]' "--no-config[don't use the configuration file]" "--no-custom-assets[don't load custom assets]" '(--no-lessopen)'--lessopen'[enable the $LESSOPEN preprocessor]' From d5aa9d8e0512128e6175897ad3f81d580ef9e007 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Mon, 10 Jun 2024 08:13:23 +0900 Subject: [PATCH 30/67] Add options generated by completions to the man page --- assets/manual/bat.1.in | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/assets/manual/bat.1.in b/assets/manual/bat.1.in index 6d952814..2bc0a3a5 100644 --- a/assets/manual/bat.1.in +++ b/assets/manual/bat.1.in @@ -201,6 +201,18 @@ Display a list of supported languages for syntax highlighting. This option exists for POSIX\-compliance reasons ('u' is for 'unbuffered'). The output is always unbuffered \- this option is simply ignored. .HP +\fB\-\-no\-custom\-assets\fR +.IP +Do not load custom assets. +.HP +\fB\-\-config\-dir\fR +.IP +Show bat's configuration directory. +.HP +\fB\-\-cache\-dir\fR +.IP +Show bat's cache directory. +.HP \fB\-\-diagnostic\fR .IP Show diagnostic information for bug reports. @@ -241,6 +253,20 @@ location of the configuration file. To generate a default configuration file, call: \fB{{PROJECT_EXECUTABLE}} --generate-config-file\fR + +These are related options: +.HP +\fB\-\-config\-file\fR +.IP +Show path to the configuration file. +.HP +\fB\-\-generate-config\-file\fR +.IP +Generates a default configuration file. +.HP +\fB\-\-no\-config\fR +.IP +Do not use the configuration file. .SH "ADDING CUSTOM LANGUAGES" {{PROJECT_EXECUTABLE}} supports Sublime Text \fB.sublime-syntax\fR language files, and can be customized to add additional languages to your local installation. To do this, add the \fB.sublime-syntax\fR language @@ -287,6 +313,16 @@ To temporarily disable the preprocessor if it is enabled by default, call: \fB{{PROJECT_EXECUTABLE}} --no-lessopen\fR +These are related options: +.HP +\fB\-\-lessopen\fR +.IP +Enable the $LESSOPEN preprocessor. +.HP +\fB\-\-no\-lessopen\fR +.IP +Disable the $LESSOPEN preprocessor if enabled (overrides --lessopen) +.PP For more information, see the "INPUT PREPROCESSOR" section of less(1). .SH "MORE INFORMATION" From 9a650e827915c7e310e73ffe1822247a5bda7064 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sun, 9 Jun 2024 21:16:31 +0900 Subject: [PATCH 31/67] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa4c8de0..610af60a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ - Update the Lisp syntax, see #2970 (@ccqpein) - Use bat's ANSI iterator during tab expansion, see #2998 (@eth-p) - Support 'statically linked binary' for aarch64 in 'Release' page, see #2992 (@tzq0301) +- Update options in shell completions and the man page of `bat`, see #2995 (@akinomyoga) ## Syntaxes From b74c125c43bb28e0b2b8f5188dac5d7348deae95 Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Sat, 6 Apr 2024 14:54:10 -0700 Subject: [PATCH 32/67] Support merging `--style` arguments The `overrides_with` clap builder option was removed because it interfered with the matcher's ability to retain all occurrences of `--style`. The behavior it covered is expressed within the new `forced_style_components` function. --- src/bin/bat/app.rs | 76 ++++++++++------ src/bin/bat/clap_app.rs | 31 ++----- src/style.rs | 194 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 250 insertions(+), 51 deletions(-) diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 0d2600b2..c95c2bd1 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -2,11 +2,13 @@ use std::collections::HashSet; use std::env; use std::io::IsTerminal; use std::path::{Path, PathBuf}; +use std::str::FromStr; use crate::{ clap_app, config::{get_args_from_config_file, get_args_from_env_opts_var, get_args_from_env_vars}, }; +use bat::style::StyleComponentList; use bat::StripAnsiMode; use clap::ArgMatches; @@ -86,7 +88,6 @@ impl App { // .. and the rest at the end cli_args.for_each(|a| args.push(a)); - args }; @@ -364,34 +365,57 @@ impl App { Ok(file_input) } + fn forced_style_components(&self) -> Option { + // No components if `--decorations=never``. + if self + .matches + .get_one::("decorations") + .map(|s| s.as_str()) + == Some("never") + { + return Some(StyleComponents(HashSet::new())); + } + + // Only line numbers if `--number`. + if self.matches.get_flag("number") { + return Some(StyleComponents(HashSet::from([ + StyleComponent::LineNumbers, + ]))); + } + + // Plain if `--plain` is specified at least once. + if self.matches.get_count("plain") > 0 { + return Some(StyleComponents(HashSet::from([StyleComponent::Plain]))); + } + + // Default behavior. + None + } + fn style_components(&self) -> Result { let matches = &self.matches; - let mut styled_components = StyleComponents( - if matches.get_one::("decorations").map(|s| s.as_str()) == Some("never") { - HashSet::new() - } else if matches.get_flag("number") { - [StyleComponent::LineNumbers].iter().cloned().collect() - } else if 0 < matches.get_count("plain") { - [StyleComponent::Plain].iter().cloned().collect() - } else { - matches - .get_one::("style") - .map(|styles| { - styles - .split(',') - .map(|style| style.parse::()) - .filter_map(|style| style.ok()) - .collect::>() - }) - .unwrap_or_else(|| vec![StyleComponent::Default]) + let mut styled_components = match self.forced_style_components() { + Some(forced_components) => forced_components, + + // Parse the `--style` arguments and merge them. + None if matches.contains_id("style") => { + let lists = matches + .get_many::("style") + .expect("styles present") + .map(|v| StyleComponentList::from_str(v)) + .collect::>>()?; + + StyleComponentList::to_components(lists, self.interactive_output) + } + + // Use the default. + None => StyleComponents(HashSet::from_iter( + StyleComponent::Default + .components(self.interactive_output) .into_iter() - .map(|style| style.components(self.interactive_output)) - .fold(HashSet::new(), |mut acc, components| { - acc.extend(components.iter().cloned()); - acc - }) - }, - ); + .cloned(), + )), + }; // If `grid` is set, remove `rule` as it is a subset of `grid`, and print a warning. if styled_components.grid() && styled_components.0.remove(&StyleComponent::Rule) { diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index e70b1a5b..8e79174b 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -1,9 +1,11 @@ +use bat::style::StyleComponentList; use clap::{ crate_name, crate_version, value_parser, Arg, ArgAction, ArgGroup, ColorChoice, Command, }; use once_cell::sync::Lazy; use std::env; use std::path::{Path, PathBuf}; +use std::str::FromStr; static VERSION: Lazy = Lazy::new(|| { #[cfg(feature = "bugreport")] @@ -419,34 +421,13 @@ pub fn build_app(interactive_output: bool) -> Command { .arg( Arg::new("style") .long("style") + .action(ArgAction::Append) .value_name("components") - .overrides_with("style") - .overrides_with("plain") - .overrides_with("number") // Cannot use claps built in validation because we have to turn off clap's delimiters .value_parser(|val: &str| { - let mut invalid_vals = val.split(',').filter(|style| { - !&[ - "auto", - "full", - "default", - "plain", - "header", - "header-filename", - "header-filesize", - "grid", - "rule", - "numbers", - "snip", - #[cfg(feature = "git")] - "changes", - ].contains(style) - }); - - if let Some(invalid) = invalid_vals.next() { - Err(format!("Unknown style, '{invalid}'")) - } else { - Ok(val.to_owned()) + match StyleComponentList::from_str(val) { + Err(err) => Err(err), + Ok(_) => Ok(val.to_owned()), } }) .help( diff --git a/src/style.rs b/src/style.rs index 652b3743..8c2cc05d 100644 --- a/src/style.rs +++ b/src/style.rs @@ -138,3 +138,197 @@ impl StyleComponents { self.0.clear(); } } + +#[derive(Debug, PartialEq)] +enum ComponentAction { + Override, + Add, + Remove, +} + +impl ComponentAction { + fn extract_from_str(string: &str) -> (ComponentAction, &str) { + match string.chars().next() { + Some('-') => (ComponentAction::Remove, string.strip_prefix('-').unwrap()), + Some('+') => (ComponentAction::Add, string.strip_prefix('+').unwrap()), + _ => (ComponentAction::Override, string), + } + } +} + +/// A list of [StyleComponent] that can be parsed from a string. +pub struct StyleComponentList(Vec<(ComponentAction, StyleComponent)>); + +impl StyleComponentList { + fn expand_into(&self, components: &mut HashSet, interactive_terminal: bool) { + for (action, component) in self.0.iter() { + let subcomponents = component.components(interactive_terminal); + + use ComponentAction::*; + match action { + Override | Add => components.extend(subcomponents), + Remove => components.retain(|c| !subcomponents.contains(c)), + } + } + } + + /// Returns `true` if any component in the list was not prefixed with `+` or `-`. + fn contains_override(&self) -> bool { + self.0.iter().any(|(a, _)| *a == ComponentAction::Override) + } + + /// Combines multiple [StyleComponentList]s into a single [StyleComponents] set. + /// + /// ## Precedence + /// The most recent list will take precedence and override all previous lists + /// unless it only contains components prefixed with `-` or `+`. When this + /// happens, the list's components will be merged into the previous list. + /// + /// ## Example + /// ```text + /// [numbers,grid] + [header,changes] -> [header,changes] + /// [numbers,grid] + [+header,-grid] -> [numbers,header] + /// ``` + pub fn to_components( + lists: impl IntoIterator, + interactive_terminal: bool, + ) -> StyleComponents { + StyleComponents( + lists + .into_iter() + .fold(HashSet::new(), |mut components, list| { + if list.contains_override() { + components.clear(); + } + + list.expand_into(&mut components, interactive_terminal); + components + }), + ) + } +} + +impl Default for StyleComponentList { + fn default() -> Self { + StyleComponentList(vec![(ComponentAction::Override, StyleComponent::Default)]) + } +} + +impl FromStr for StyleComponentList { + type Err = Error; + + fn from_str(s: &str) -> Result { + Ok(StyleComponentList( + s.split(",") + .map(|s| ComponentAction::extract_from_str(s)) // If the component starts with "-", it's meant to be removed + .map(|(a, s)| Ok((a, StyleComponent::from_str(s)?))) + .collect::>>()?, + )) + } +} + +#[cfg(test)] +mod test { + use std::collections::HashSet; + use std::str::FromStr; + + use super::ComponentAction::*; + use super::StyleComponent::*; + use super::StyleComponentList; + + #[test] + pub fn style_component_list_parse() { + assert_eq!( + StyleComponentList::from_str("grid,+numbers,snip,-snip,header") + .expect("no error") + .0, + vec![ + (Override, Grid), + (Add, LineNumbers), + (Override, Snip), + (Remove, Snip), + (Override, Header), + ] + ); + + assert!(StyleComponentList::from_str("not-a-component").is_err()); + assert!(StyleComponentList::from_str("grid,not-a-component").is_err()); + assert!(StyleComponentList::from_str("numbers,-not-a-component").is_err()); + } + + #[test] + pub fn style_component_list_to_components() { + assert_eq!( + StyleComponentList::to_components( + vec![StyleComponentList::from_str("grid,numbers").expect("no error")], + false + ) + .0, + HashSet::from([Grid, LineNumbers]) + ); + } + + #[test] + pub fn style_component_list_to_components_removes_negated() { + assert_eq!( + StyleComponentList::to_components( + vec![StyleComponentList::from_str("grid,numbers,-grid").expect("no error")], + false + ) + .0, + HashSet::from([LineNumbers]) + ); + } + + #[test] + pub fn style_component_list_to_components_expands_subcomponents() { + assert_eq!( + StyleComponentList::to_components( + vec![StyleComponentList::from_str("full").expect("no error")], + false + ) + .0, + HashSet::from_iter(Full.components(true).to_owned()) + ); + } + + #[test] + pub fn style_component_list_expand_negates_subcomponents() { + assert!(!StyleComponentList::to_components( + vec![StyleComponentList::from_str("full,-numbers").expect("no error")], + true + ) + .numbers()); + } + + #[test] + pub fn style_component_list_to_components_precedence_overrides_previous_lists() { + assert_eq!( + StyleComponentList::to_components( + vec![ + StyleComponentList::from_str("grid").expect("no error"), + StyleComponentList::from_str("numbers").expect("no error"), + ], + false + ) + .0, + HashSet::from([LineNumbers]) + ); + } + + #[test] + pub fn style_component_list_to_components_precedence_merges_previous_lists() { + assert_eq!( + StyleComponentList::to_components( + vec![ + StyleComponentList::from_str("grid,header").expect("no error"), + StyleComponentList::from_str("-grid").expect("no error"), + StyleComponentList::from_str("+numbers").expect("no error"), + ], + false + ) + .0, + HashSet::from([HeaderFilename, LineNumbers]) + ); + } +} From 6e91ba83b7663d22f88788d89595513e55b4ec0f Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Sat, 6 Apr 2024 15:04:20 -0700 Subject: [PATCH 33/67] Update clap/docs for merging `--style` arguments --- README.md | 10 ++++++++++ doc/long-help.txt | 6 ++++++ src/bin/bat/clap_app.rs | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 1e42e501..016fe834 100644 --- a/README.md +++ b/README.md @@ -515,6 +515,16 @@ and line numbers but no grid and no file header. Set the `BAT_STYLE` environment variable to make these changes permanent or use `bat`s [configuration file](https://github.com/sharkdp/bat#configuration-file). +>[!tip] +> If you specify a default style in `bat`'s config file, you can change which components +> are displayed during a single run of `bat` using the `--style` command-line argument. +> By prefixing a component with `+` or `-`, it can be added or removed from the current style. +> +> For example, if your config contains `--style=full,-snip`, you can run bat with +> `--style=-grid,+snip` to remove the grid and add back the `snip` component. +> Or, if you want to override the styles completely, you use `--style=numbers` to +> only show the line numbers. + ### Adding new syntaxes / language definitions Should you find that a particular syntax is not available within `bat`, you can follow these diff --git a/doc/long-help.txt b/doc/long-help.txt index d9cdce39..2b03490f 100644 --- a/doc/long-help.txt +++ b/doc/long-help.txt @@ -134,6 +134,12 @@ Options: set a default style, add the '--style=".."' option to the configuration file or export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). + When styles are specified in multiple places, the "nearest" set of styles take precedence. + The command-line arguments are the highest priority, followed by the BAT_STYLE environment + variable, and then the configuration file. If any set of styles consists entirely of + components prefixed with "+" or "-", it will modify the previous set of styles instead of + replacing them. + By default, the following components are enabled: changes, grid, header-filename, numbers, snip diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 8e79174b..33dde980 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -442,6 +442,12 @@ pub fn build_app(interactive_output: bool) -> Command { pre-defined style ('full'). To set a default style, add the \ '--style=\"..\"' option to the configuration file or export the \ BAT_STYLE environment variable (e.g.: export BAT_STYLE=\"..\").\n\n\ + When styles are specified in multiple places, the \"nearest\" set \ + of styles take precedence. The command-line arguments are the highest \ + priority, followed by the BAT_STYLE environment variable, and then \ + the configuration file. If any set of styles consists entirely of \ + components prefixed with \"+\" or \"-\", it will modify the \ + previous set of styles instead of replacing them.\n\n\ By default, the following components are enabled:\n \ changes, grid, header-filename, numbers, snip\n\n\ Possible values:\n\n \ From 93b25d75a0db2bc5fef4e147a92af55373781046 Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Sat, 6 Apr 2024 17:05:46 -0700 Subject: [PATCH 34/67] Join env var options with "=" instead of " " Joining them with a space was causing certain styles (e.g. `-grid`) to be misinterpreted as a separate option. --- src/bin/bat/config.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bin/bat/config.rs b/src/bin/bat/config.rs index 9e38dfa4..6fa18f09 100644 --- a/src/bin/bat/config.rs +++ b/src/bin/bat/config.rs @@ -146,8 +146,11 @@ pub fn get_args_from_env_vars() -> Vec { ("--style", "BAT_STYLE"), ] .iter() - .filter_map(|(flag, key)| env::var(key).ok().map(|var| [flag.to_string(), var])) - .flatten() + .filter_map(|(flag, key)| { + env::var(key) + .ok() + .map(|var| [flag.to_string(), var].join("=")) + }) .map(|a| a.into()) .collect() } From 180a77ee99e8b5bc9f4cdb017788deb595968d5f Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Sat, 6 Apr 2024 17:21:03 -0700 Subject: [PATCH 35/67] Add integration tests for merging styles A huge thanks to @einfachIrgendwer0815 for helping me make sure these tests work under the MSRV CI job. --- tests/integration_tests.rs | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index d6009361..8df4327c 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -2810,3 +2810,71 @@ fn strip_ansi_auto_does_not_strip_ansi_when_plain_text_by_option() { assert!(output.contains("\x1B[33mYellow")) } + +// Tests that style components can be removed with `-component`. +#[test] +fn style_components_can_be_removed() { + bat() + .arg({ + #[cfg(not(feature = "git"))] + { + "--style=full,-grid" + } + #[cfg(feature = "git")] + { + "--style=full,-grid,-changes" + } + }) + .arg("--decorations=always") + .arg("--color=never") + .write_stdin("test") + .assert() + .success() + .stdout(" STDIN\n Size: -\n 1 test\n") + .stderr(""); +} + +// Tests that style components are chosen based on the rightmost `--style` argument. +#[test] +fn style_components_can_be_overidden() { + bat() + .arg("--style=full") + .arg("--style=header,numbers") + .arg("--decorations=always") + .arg("--color=never") + .write_stdin("test") + .assert() + .success() + .stdout(" STDIN\n 1 test\n") + .stderr(""); +} + +// Tests that style components can be merged across multiple `--style` arguments. +#[test] +fn style_components_will_merge() { + bat() + .arg("--style=header,grid") + .arg("--style=-grid,+numbers") + .arg("--decorations=always") + .arg("--color=never") + .write_stdin("test") + .assert() + .success() + .stdout(" STDIN\n 1 test\n") + .stderr(""); +} + +// Tests that style components can be merged with the `BAT_STYLE` environment variable. +#[test] +fn style_components_will_merge_with_env_var() { + bat() + .env("BAT_STYLE", "header,grid") + .arg("--style=-grid,+numbers") + .arg("--decorations=always") + .arg("--color=never") + .write_stdin("test") + .assert() + .success() + .stdout(" STDIN\n 1 test\n") + .stderr(""); +} From aa3ec109b74eb6e23d1fe15ade3087ca8430eeb2 Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Mon, 10 Jun 2024 17:39:55 -0700 Subject: [PATCH 36/67] First StyleComponentList should remove from 'auto' style. This happens when there are no `--style` arguments other than the one passed in as a command line argument. Prior to this change, removing a style component (e.g. `--style=-numbers`) would remove the component from an empty style component set, resulting in no styles at all. That behaviour was less intuitive than the new behaviour, which starts out with the default components and removes the line numbers. --- src/bin/bat/app.rs | 2 +- src/style.rs | 54 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index c95c2bd1..d6628668 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -405,7 +405,7 @@ impl App { .map(|v| StyleComponentList::from_str(v)) .collect::>>()?; - StyleComponentList::to_components(lists, self.interactive_output) + StyleComponentList::to_components(lists, self.interactive_output, true) } // Use the default. diff --git a/src/style.rs b/src/style.rs index 8c2cc05d..b8d8b09f 100644 --- a/src/style.rs +++ b/src/style.rs @@ -189,22 +189,27 @@ impl StyleComponentList { /// [numbers,grid] + [header,changes] -> [header,changes] /// [numbers,grid] + [+header,-grid] -> [numbers,header] /// ``` + /// + /// ## Parameters + /// - `with_default`: If true, the styles lists will build upon the StyleComponent::Auto style. pub fn to_components( lists: impl IntoIterator, interactive_terminal: bool, + with_default: bool, ) -> StyleComponents { - StyleComponents( - lists - .into_iter() - .fold(HashSet::new(), |mut components, list| { - if list.contains_override() { - components.clear(); - } + let mut components: HashSet = HashSet::new(); + if with_default { + components.extend(StyleComponent::Auto.components(interactive_terminal)) + } - list.expand_into(&mut components, interactive_terminal); - components - }), - ) + StyleComponents(lists.into_iter().fold(components, |mut components, list| { + if list.contains_override() { + components.clear(); + } + + list.expand_into(&mut components, interactive_terminal); + components + })) } } @@ -233,6 +238,7 @@ mod test { use std::str::FromStr; use super::ComponentAction::*; + use super::StyleComponent; use super::StyleComponent::*; use super::StyleComponentList; @@ -261,6 +267,7 @@ mod test { assert_eq!( StyleComponentList::to_components( vec![StyleComponentList::from_str("grid,numbers").expect("no error")], + false, false ) .0, @@ -273,6 +280,7 @@ mod test { assert_eq!( StyleComponentList::to_components( vec![StyleComponentList::from_str("grid,numbers,-grid").expect("no error")], + false, false ) .0, @@ -285,6 +293,7 @@ mod test { assert_eq!( StyleComponentList::to_components( vec![StyleComponentList::from_str("full").expect("no error")], + false, false ) .0, @@ -296,7 +305,8 @@ mod test { pub fn style_component_list_expand_negates_subcomponents() { assert!(!StyleComponentList::to_components( vec![StyleComponentList::from_str("full,-numbers").expect("no error")], - true + true, + false ) .numbers()); } @@ -309,6 +319,7 @@ mod test { StyleComponentList::from_str("grid").expect("no error"), StyleComponentList::from_str("numbers").expect("no error"), ], + false, false ) .0, @@ -325,10 +336,29 @@ mod test { StyleComponentList::from_str("-grid").expect("no error"), StyleComponentList::from_str("+numbers").expect("no error"), ], + false, false ) .0, HashSet::from([HeaderFilename, LineNumbers]) ); } + + #[test] + pub fn style_component_list_default_builds_on_auto() { + assert_eq!( + StyleComponentList::to_components( + vec![StyleComponentList::from_str("-numbers").expect("no error"),], + true, + true + ) + .0, + { + let mut expected: HashSet = HashSet::new(); + expected.extend(Auto.components(true)); + expected.remove(&LineNumbers); + expected + } + ); + } } From 39684b85ad6c14819a7780c2feef37a888ac7f43 Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Sat, 6 Apr 2024 18:10:01 -0700 Subject: [PATCH 37/67] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 610af60a..ea47b58f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - `PrettyPrinter::squeeze_empty_lines` to support line squeezing for bat as a library, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815) - Syntax highlighting for JavaScript files that start with `#!/usr/bin/env bun` #2913 (@sharunkumar) - `bat --strip-ansi={never,always,auto}` to remove ANSI escape sequences from bat's input, see #2999 (@eth-p) +- Add or remove individual style components without replacing all styles #2929 (@eth-p) ## Bugfixes From 13317b0a3b3814aebdb7bda14ee7a6d35d3edb45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:47:46 +0000 Subject: [PATCH 38/67] Bump expect-test from 1.4.1 to 1.5.0 (#3055) Bumps [expect-test](https://github.com/rust-analyzer/expect-test) from 1.4.1 to 1.5.0. - [Changelog](https://github.com/rust-analyzer/expect-test/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-analyzer/expect-test/compare/v1.4.1...v1.5.0) --- updated-dependencies: - dependency-name: expect-test dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c49ff655..e260d57e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -463,9 +463,9 @@ dependencies = [ [[package]] name = "expect-test" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d9eafeadd538e68fb28016364c9732d78e420b9ff8853fa5e4058861e9f8d3" +checksum = "9e0be0a561335815e06dab7c62e50353134c796e7a6155402a64bcff66b6a5e0" dependencies = [ "dissimilar", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 6170905a..c939c500 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,7 +90,7 @@ plist = "1.6.0" [dev-dependencies] assert_cmd = "2.0.12" -expect-test = "1.4.1" +expect-test = "1.5.0" serial_test = { version = "2.0.0", default-features = false } predicates = "3.1.0" wait-timeout = "0.2.0" From d8d0b77568fe903b2d3e92e58b74b0f70d7fd636 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 03:14:26 +0000 Subject: [PATCH 39/67] Bump indexmap from 2.2.6 to 2.3.0 (#3057) Bumps [indexmap](https://github.com/indexmap-rs/indexmap) from 2.2.6 to 2.3.0. - [Changelog](https://github.com/indexmap-rs/indexmap/blob/master/RELEASES.md) - [Commits](https://github.com/indexmap-rs/indexmap/compare/2.2.6...2.3.0) --- updated-dependencies: - dependency-name: indexmap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e260d57e..5a4b616d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -647,9 +647,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown 0.14.1", diff --git a/Cargo.toml b/Cargo.toml index c939c500..720e629b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,7 +102,7 @@ nix = { version = "0.26.4", default-features = false, features = ["term"] } [build-dependencies] anyhow = "1.0.86" -indexmap = { version = "2.2.6", features = ["serde"] } +indexmap = { version = "2.3.0", features = ["serde"] } itertools = "0.13.0" once_cell = "1.18" regex = "1.10.2" From b662fec214daaa77a67f08d8fbd2e81915d6e0bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 03:28:12 +0000 Subject: [PATCH 40/67] Bump ansi_colours from 1.2.2 to 1.2.3 (#3058) Bumps [ansi_colours](https://github.com/mina86/ansi_colours) from 1.2.2 to 1.2.3. - [Commits](https://github.com/mina86/ansi_colours/commits) --- updated-dependencies: - dependency-name: ansi_colours dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5a4b616d..1168501a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ dependencies = [ [[package]] name = "ansi_colours" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a1558bd2075d341b9ca698ec8eb6fcc55a746b1fc4255585aad5b141d918a80" +checksum = "14eec43e0298190790f41679fe69ef7a829d2a2ddd78c8c00339e84710e435fe" dependencies = [ "rgb", ] From 7f089ead62508675749fe3da5f9d009ba38224cd Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Fri, 31 May 2024 18:20:16 +0200 Subject: [PATCH 41/67] Add option `--binary` `--binary` allows to specify how to deal with binary content. Current options are not printing anything or treating the binary data as text. --- doc/long-help.txt | 7 +++++++ doc/short-help.txt | 2 ++ src/bin/bat/app.rs | 6 ++++++ src/bin/bat/clap_app.rs | 16 ++++++++++++++++ src/config.rs | 5 ++++- src/lib.rs | 2 +- src/nonprintable_notation.rs | 12 ++++++++++++ src/printer.rs | 19 +++++++++++++++---- 8 files changed, 63 insertions(+), 6 deletions(-) diff --git a/doc/long-help.txt b/doc/long-help.txt index 2b03490f..87fb5d96 100644 --- a/doc/long-help.txt +++ b/doc/long-help.txt @@ -20,6 +20,13 @@ Options: * unicode (␇, ␊, ␀, ..) * caret (^G, ^J, ^@, ..) + --binary + How to treat binary content. (default: no-printing) + + Possible values: + * no-printing: do not print any binary content + * as-text: treat binary content as normal text + -p, --plain... Only show plain style, no decorations. This is an alias for '--style=plain'. When '-p' is used twice ('-pp'), it also disables automatic paging (alias for '--style=plain diff --git a/doc/short-help.txt b/doc/short-help.txt index 305bbf3d..16b9eb05 100644 --- a/doc/short-help.txt +++ b/doc/short-help.txt @@ -11,6 +11,8 @@ Options: Show non-printable characters (space, tab, newline, ..). --nonprintable-notation Set notation for non-printable characters. + --binary + How to treat binary content. (default: no-printing) -p, --plain... Show plain style (alias for '--style=plain'). -l, --language diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index d6628668..4d52c73d 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -9,6 +9,7 @@ use crate::{ config::{get_args_from_config_file, get_args_from_env_opts_var, get_args_from_env_vars}, }; use bat::style::StyleComponentList; +use bat::BinaryBehavior; use bat::StripAnsiMode; use clap::ArgMatches; @@ -193,6 +194,11 @@ impl App { Some("caret") => NonprintableNotation::Caret, _ => unreachable!("other values for --nonprintable-notation are not allowed"), }, + binary: match self.matches.get_one::("binary").map(|s| s.as_str()) { + Some("as-text") => BinaryBehavior::AsText, + Some("no-printing") => BinaryBehavior::NoPrinting, + _ => unreachable!("other values for --binary are not allowed"), + }, wrapping_mode: if self.interactive_output || maybe_term_width.is_some() { if !self.matches.get_flag("chop-long-lines") { match self.matches.get_one::("wrap").map(|s| s.as_str()) { diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 33dde980..4327fa15 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -77,6 +77,22 @@ pub fn build_app(interactive_output: bool) -> Command { * caret (^G, ^J, ^@, ..)", ), ) + .arg( + Arg::new("binary") + .long("binary") + .action(ArgAction::Set) + .default_value("no-printing") + .value_parser(["no-printing", "as-text"]) + .value_name("behavior") + .hide_default_value(true) + .help("How to treat binary content. (default: no-printing)") + .long_help( + "How to treat binary content. (default: no-printing)\n\n\ + Possible values:\n \ + * no-printing: do not print any binary content\n \ + * as-text: treat binary content as normal text", + ), + ) .arg( Arg::new("plain") .overrides_with("plain") diff --git a/src/config.rs b/src/config.rs index eb7df8ee..eb44281c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,5 @@ use crate::line_range::{HighlightedLineRanges, LineRanges}; -use crate::nonprintable_notation::NonprintableNotation; +use crate::nonprintable_notation::{BinaryBehavior, NonprintableNotation}; #[cfg(feature = "paging")] use crate::paging::PagingMode; use crate::style::StyleComponents; @@ -44,6 +44,9 @@ pub struct Config<'a> { /// The configured notation for non-printable characters pub nonprintable_notation: NonprintableNotation, + /// How to treat binary content + pub binary: BinaryBehavior, + /// The character width of the terminal pub term_width: usize, diff --git a/src/lib.rs b/src/lib.rs index 23c4a800..a015913e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,7 +52,7 @@ mod terminal; mod vscreen; pub(crate) mod wrapping; -pub use nonprintable_notation::NonprintableNotation; +pub use nonprintable_notation::{BinaryBehavior, NonprintableNotation}; pub use preprocessor::StripAnsiMode; pub use pretty_printer::{Input, PrettyPrinter, Syntax}; pub use syntax_mapping::{MappingTarget, SyntaxMapping}; diff --git a/src/nonprintable_notation.rs b/src/nonprintable_notation.rs index ff09aca6..9f8d7cb8 100644 --- a/src/nonprintable_notation.rs +++ b/src/nonprintable_notation.rs @@ -10,3 +10,15 @@ pub enum NonprintableNotation { #[default] Unicode, } + +/// How to treat binary content +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum BinaryBehavior { + /// Do not print any binary content + #[default] + NoPrinting, + + /// Treat binary content as normal text + AsText, +} diff --git a/src/printer.rs b/src/printer.rs index e9bea3fd..3398b217 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -35,6 +35,7 @@ use crate::style::StyleComponent; use crate::terminal::{as_terminal_escaped, to_ansi_color}; use crate::vscreen::{AnsiStyle, EscapeSequence, EscapeSequenceIterator}; use crate::wrapping::WrappingMode; +use crate::BinaryBehavior; use crate::StripAnsiMode; const ANSI_UNDERLINE_ENABLE: EscapeSequence = EscapeSequence::CSI { @@ -458,7 +459,10 @@ impl<'a> Printer for InteractivePrinter<'a> { } if !self.config.style_components.header() { - if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable { + if Some(ContentType::BINARY) == self.content_type + && !self.config.show_nonprintable + && !matches!(self.config.binary, BinaryBehavior::AsText) + { writeln!( handle, "{}: Binary content from {} will not be printed to the terminal \ @@ -539,7 +543,10 @@ impl<'a> Printer for InteractivePrinter<'a> { })?; if self.config.style_components.grid() { - if self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable { + if self.content_type.map_or(false, |c| c.is_text()) + || self.config.show_nonprintable + || matches!(self.config.binary, BinaryBehavior::AsText) + { self.print_horizontal_line(handle, '┼')?; } else { self.print_horizontal_line(handle, '┴')?; @@ -551,7 +558,9 @@ impl<'a> Printer for InteractivePrinter<'a> { fn print_footer(&mut self, handle: &mut OutputHandle, _input: &OpenedInput) -> Result<()> { if self.config.style_components.grid() - && (self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable) + && (self.content_type.map_or(false, |c| c.is_text()) + || self.config.show_nonprintable + || matches!(self.config.binary, BinaryBehavior::AsText)) { self.print_horizontal_line(handle, '┴') } else { @@ -599,7 +608,9 @@ impl<'a> Printer for InteractivePrinter<'a> { .into() } else { let mut line = match self.content_type { - Some(ContentType::BINARY) | None => { + Some(ContentType::BINARY) | None + if !matches!(self.config.binary, BinaryBehavior::AsText) => + { return Ok(()); } Some(ContentType::UTF_16LE) => UTF_16LE.decode_with_bom_removal(line_buffer).0, From 7cc231b82b7f3ddd8395a783a0bf59e35a6b5b44 Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Fri, 31 May 2024 18:32:28 +0200 Subject: [PATCH 42/67] Test `--binary=as-text` --- tests/integration_tests.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 8df4327c..2cc4eb8b 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1929,6 +1929,16 @@ fn show_all_with_unicode() { .stderr(""); } +#[test] +fn binary_as_text() { + bat() + .arg("--binary=as-text") + .arg("control_characters.txt") + .assert() + .stdout("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7F") + .stderr(""); +} + #[test] fn no_paging_arg() { bat() From a769a3d8137f863634a14ae5741d7ee98299367f Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Fri, 31 May 2024 20:58:25 +0200 Subject: [PATCH 43/67] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea47b58f..ec662247 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Syntax highlighting for JavaScript files that start with `#!/usr/bin/env bun` #2913 (@sharunkumar) - `bat --strip-ansi={never,always,auto}` to remove ANSI escape sequences from bat's input, see #2999 (@eth-p) - Add or remove individual style components without replacing all styles #2929 (@eth-p) +- Add option `--binary=as-text` for printing binary content, see issue #2974 and PR #2976 (@einfachIrgendwer0815) ## Bugfixes From 0c3b22e0f0ed1a371923b2e4df130f646c564772 Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Sat, 1 Jun 2024 00:13:03 +0200 Subject: [PATCH 44/67] Run syntax highlighting when `--binary=as-text` --- src/printer.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/printer.rs b/src/printer.rs index 3398b217..95017188 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -269,7 +269,8 @@ impl<'a> InteractivePrinter<'a> { .content_type .map_or(false, |c| c.is_binary() && !config.show_nonprintable); - let needs_to_match_syntax = !is_printing_binary + let needs_to_match_syntax = (!is_printing_binary + || matches!(config.binary, BinaryBehavior::AsText)) && (config.colored_output || config.strip_ansi == StripAnsiMode::Auto); let (is_plain_text, highlighter_from_set) = if needs_to_match_syntax { From 0603f0b844707d3f9de7a9a7f110fd5a4f2743a9 Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Sun, 25 Aug 2024 10:54:46 +0200 Subject: [PATCH 45/67] Don't output default theme info to piped stdout --- src/bin/bat/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index 4528a60b..3b74ec75 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -202,7 +202,7 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result< let default_theme = HighlightingAssets::default_theme(); for theme in assets.themes() { - let default_theme_info = if default_theme == theme { + let default_theme_info = if !config.loop_through && default_theme == theme { " (default)" } else { "" From 5be9d195003c00754885b2e3bb00cf13b6e707d2 Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Sun, 25 Aug 2024 11:07:29 +0200 Subject: [PATCH 46/67] Reinforce tests for `--list-themes` --- tests/integration_tests.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 8df4327c..c083a941 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -300,6 +300,7 @@ fn list_themes_without_colors() { bat() .arg("--color=never") + .arg("--decorations=always") // trick bat into setting `Config::loop_through` to false .arg("--list-themes") .assert() .success() @@ -307,6 +308,15 @@ fn list_themes_without_colors() { .stdout(predicate::str::contains(default_theme_chunk).normalize()); } +#[test] +fn list_themes_to_piped_output() { + bat() + .arg("--list-themes") + .assert() + .success() + .stdout(predicate::str::contains("(default)").not()); +} + #[test] #[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)] fn short_help() { From c1772b7793f94c50fba2efc2b6b8091654cff010 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 02:45:53 +0000 Subject: [PATCH 47/67] Bump plist from 1.6.0 to 1.7.0 (#3076) Bumps [plist](https://github.com/ebarnard/rust-plist) from 1.6.0 to 1.7.0. - [Release notes](https://github.com/ebarnard/rust-plist/releases) - [Commits](https://github.com/ebarnard/rust-plist/compare/v1.6.0...v1.7.0) --- updated-dependencies: - dependency-name: plist dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 28 ++++++---------------------- Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1168501a..f185750b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,9 +103,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.21.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bat" @@ -716,15 +716,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "line-wrap" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" -dependencies = [ - "safemem", -] - [[package]] name = "linked-hash-map" version = "0.5.6" @@ -892,13 +883,12 @@ checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] name = "plist" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5699cc8a63d1aa2b1ee8e12b9ad70ac790d65788cd36101fa37f87ea46c4cef" +checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ "base64", "indexmap", - "line-wrap", "quick-xml", "serde", "time", @@ -957,9 +947,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" dependencies = [ "memchr", ] @@ -1087,12 +1077,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" - [[package]] name = "same-file" version = "1.0.6" diff --git a/Cargo.toml b/Cargo.toml index 720e629b..0740b291 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,7 +86,7 @@ features = ["wrap_help", "cargo"] [target.'cfg(target_os = "macos")'.dependencies] home = "0.5.9" -plist = "1.6.0" +plist = "1.7.0" [dev-dependencies] assert_cmd = "2.0.12" From ffa74a7f499bc1d3ceb62bff3f8e1453a87f4ca6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 03:05:26 +0000 Subject: [PATCH 48/67] Bump serde from 1.0.199 to 1.0.209 (#3077) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.199 to 1.0.209. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.199...v1.0.209) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f185750b..4fcb870b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1100,18 +1100,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.199" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.199" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", From ed7789d9b75cf55a6b598b2157bf634cfccb8e1c Mon Sep 17 00:00:00 2001 From: Mikael Vaaltola Date: Wed, 18 Sep 2024 12:51:43 +0300 Subject: [PATCH 49/67] Associate GeoJSON `.geojson` files with `json` syntax (fixes #3083) --- CHANGELOG.md | 1 + src/syntax_mapping/builtins/common/50-json.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea47b58f..243f7449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ - Associate JSON with Comments `.jsonc` with `json` syntax, see #2795 (@mxaddict) - Associate JSON-LD `.jsonld` files with `json` syntax, see #3037 (@vorburger) - Associate `.textproto` files with `ProtoBuf` syntax, see #3038 (@vorburger) +- Associate GeoJSON `.geojson` files with `json` syntax, see #3084 (@mvaaltola) - Associate `.aws/{config,credentials}`, see #2795 (@mxaddict) - Associate Wireguard config `/etc/wireguard/*.conf`, see #2874 (@cyqsimon) - Add support for [CFML](https://www.adobe.com/products/coldfusion-family.html), see #3031 (@brenton-at-pieces) diff --git a/src/syntax_mapping/builtins/common/50-json.toml b/src/syntax_mapping/builtins/common/50-json.toml index 7d33b6fe..3198c4f3 100644 --- a/src/syntax_mapping/builtins/common/50-json.toml +++ b/src/syntax_mapping/builtins/common/50-json.toml @@ -1,3 +1,3 @@ # JSON Lines is a simple variation of JSON #2535 [mappings] -"JSON" = ["*.jsonl", "*.jsonc", "*.jsonld"] +"JSON" = ["*.jsonl", "*.jsonc", "*.jsonld", "*.geojson"] From a0226f5670506c8e691cf05f3a752d8a5b2eb0a5 Mon Sep 17 00:00:00 2001 From: flytam Date: Thu, 8 Aug 2024 20:34:48 +0800 Subject: [PATCH 50/67] Update Chinese version translation of README.md --- doc/README-zh.md | 50 ++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/doc/README-zh.md b/doc/README-zh.md index 007afb3e..9f2d202e 100644 --- a/doc/README-zh.md +++ b/doc/README-zh.md @@ -616,63 +616,59 @@ iconv -f ISO-8859-1 -t UTF-8 my-file.php | bat 注意: 当`bat`无法识别语言时你可能会需要`-l`/`--language`参数。 -## Development +## 开发 ```bash -# Recursive clone to retrieve all submodules +# 递归 clone 以获取所有子模块 git clone --recursive https://github.com/sharkdp/bat -# Build (debug version) +# 构建(调试版本) cd bat cargo build --bins -# Run unit tests and integration tests +# 运行单元测试和集成测试 cargo test -# Install (release version) +# 安装(发布版本) cargo install --path . --locked -# Build a bat binary with modified syntaxes and themes +# 使用修改后的语法和主题构建一个 bat 二进制文件 bash assets/create.sh cargo install --path . --locked --force ``` -If you want to build an application that uses `bat`s pretty-printing -features as a library, check out the [the API documentation](https://docs.rs/bat/). -Note that you have to use either `regex-onig` or `regex-fancy` as a feature -when you depend on `bat` as a library. +如果你想构建一个使用 `bat` 美化打印功能的应用程序,请查看 [API 文档](https://docs.rs/bat/)。请注意,当你依赖 `bat` 作为库时,必须使用 `regex-onig` 或 `regex-fancy` 作为特性。 -## Contributing +## 贡献指南 -Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide. +请查看 [`CONTRIBUTING.md`](CONTRIBUTING.md) 指南。 -## Maintainers +## 维护者 - [sharkdp](https://github.com/sharkdp) - [eth-p](https://github.com/eth-p) - [keith-hall](https://github.com/keith-hall) - [Enselic](https://github.com/Enselic) -## Security vulnerabilities +## 安全漏洞 -Please contact [David Peter](https://david-peter.de/) via email if you want to report a vulnerability in `bat`. +如果你想报告 `bat` 中的漏洞,请通过邮件联系 [David Peter](https://david-peter.de/)。 -## Project goals and alternatives +## 项目目标和替代方案 -`bat` tries to achieve the following goals: +`bat` 试图实现以下目标: -- Provide beautiful, advanced syntax highlighting -- Integrate with Git to show file modifications -- Be a drop-in replacement for (POSIX) `cat` -- Offer a user-friendly command-line interface +- 提供美观的高级语法高亮 +- 与 Git 集成以显示文件修改 +- 成为 (POSIX) `cat` 的替代品 +- 提供用户友好的命令行界面 -There are a lot of alternatives, if you are looking for similar programs. See -[this document](doc/alternatives.md) for a comparison. +如果你在寻找类似的程序,有很多替代方案。请参阅[本文档](doc/alternatives.md)进行比较。 -## License +## 许可证 -Copyright (c) 2018-2021 [bat-developers](https://github.com/sharkdp/bat). +版权所有 (c) 2018-2021 [bat-developers](https://github.com/sharkdp/bat)。 -`bat` is made available under the terms of either the MIT License or the Apache License 2.0, at your option. +`bat` 可根据 MIT 许可证或 Apache 许可证 2.0 的条款使用,任选其一。 -See the [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) files for license details. +有关许可证的详细信息,请参阅 [LICENSE-APACHE](LICENSE-APACHE) 和 [LICENSE-MIT](LICENSE-MIT) 文件。 From bc69ffb0f0732c64af5d7751e074e6bc17342c69 Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Thu, 26 Sep 2024 21:06:07 +0200 Subject: [PATCH 51/67] Map `*.mkd` files to `Markdown` syntax (#3061) --- CHANGELOG.md | 1 + src/syntax_mapping/builtins/common/50-markdown.toml | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 src/syntax_mapping/builtins/common/50-markdown.toml diff --git a/CHANGELOG.md b/CHANGELOG.md index 243f7449..d2ec2da9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ - Associate `.aws/{config,credentials}`, see #2795 (@mxaddict) - Associate Wireguard config `/etc/wireguard/*.conf`, see #2874 (@cyqsimon) - Add support for [CFML](https://www.adobe.com/products/coldfusion-family.html), see #3031 (@brenton-at-pieces) +- Map `*.mkd` files to `Markdown` syntax, see issue #3060 and PR #3061 (@einfachIrgendwer0815) ## Themes diff --git a/src/syntax_mapping/builtins/common/50-markdown.toml b/src/syntax_mapping/builtins/common/50-markdown.toml new file mode 100644 index 00000000..aa0531d2 --- /dev/null +++ b/src/syntax_mapping/builtins/common/50-markdown.toml @@ -0,0 +1,2 @@ +[mappings] +"Markdown" = ["*.mkd"] From 9d635627dc27cddf3414b75b6e11abc3024a3950 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 02:40:45 +0000 Subject: [PATCH 52/67] Bump globset from 0.4.14 to 0.4.15 (#3090) Bumps [globset](https://github.com/BurntSushi/ripgrep) from 0.4.14 to 0.4.15. - [Release notes](https://github.com/BurntSushi/ripgrep/releases) - [Changelog](https://github.com/BurntSushi/ripgrep/blob/master/CHANGELOG.md) - [Commits](https://github.com/BurntSushi/ripgrep/compare/globset-0.4.14...ignore-0.4.15) --- updated-dependencies: - dependency-name: globset dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4fcb870b..7b992e72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -583,9 +583,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" dependencies = [ "aho-corasick", "bstr", From 16a79d38c2ca82e4412d453ddfc44cdfe6367ebe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 03:02:02 +0000 Subject: [PATCH 53/67] Bump once_cell from 1.19.0 to 1.20.1 (#3091) Bumps [once_cell](https://github.com/matklad/once_cell) from 1.19.0 to 1.20.1. - [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md) - [Commits](https://github.com/matklad/once_cell/compare/v1.19.0...v1.20.1) --- updated-dependencies: - dependency-name: once_cell dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 13 +++++++++++-- Cargo.toml | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b992e72..ff10f09c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -802,9 +802,12 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "onig" @@ -894,6 +897,12 @@ dependencies = [ "time", ] +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "powerfmt" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 0740b291..cbb84a6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ ansi_colours = "^1.2" bincode = "1.0" console = "0.15.8" flate2 = "1.0" -once_cell = "1.19" +once_cell = "1.20" thiserror = "1.0" wild = { version = "2.2", optional = true } content_inspector = "0.2.4" @@ -104,7 +104,7 @@ nix = { version = "0.26.4", default-features = false, features = ["term"] } anyhow = "1.0.86" indexmap = { version = "2.3.0", features = ["serde"] } itertools = "0.13.0" -once_cell = "1.18" +once_cell = "1.20" regex = "1.10.2" serde = "1.0" serde_derive = "1.0" From c59dad0cae45d7aa84ad87583d6b6904b30839b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 03:19:34 +0000 Subject: [PATCH 54/67] Bump git2 from 0.18.3 to 0.19.0 (#3092) Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.18.3 to 0.19.0. - [Changelog](https://github.com/rust-lang/git2-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/git2-rs/compare/git2-0.18.3...git2-0.19.0) --- updated-dependencies: - dependency-name: git2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff10f09c..e2f6ef7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -564,9 +564,9 @@ dependencies = [ [[package]] name = "git2" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "232e6a7bfe35766bf715e55a88b39a700596c0ccfd88cd3680b4cdb40d66ef70" +checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" dependencies = [ "bitflags 2.4.0", "libc", @@ -694,9 +694,9 @@ checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libgit2-sys" -version = "0.16.2+1.7.2" +version = "0.17.0+1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" +checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index cbb84a6c..f5ef6af9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ os_str_bytes = { version = "~7.0", optional = true } run_script = { version = "^0.10.1", optional = true} [dependencies.git2] -version = "0.18" +version = "0.19" optional = true default-features = false From 61c9f312c9d10103b33b7d8069401304ca938f06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 03:36:57 +0000 Subject: [PATCH 55/67] Bump flate2 from 1.0.30 to 1.0.34 (#3093) Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.30 to 1.0.34. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Changelog](https://github.com/rust-lang/flate2-rs/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.30...1.0.34) --- updated-dependencies: - dependency-name: flate2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2f6ef7c..42db6b5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,10 +3,10 @@ version = 3 [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" @@ -489,9 +489,9 @@ checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide", @@ -752,11 +752,11 @@ checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] From fd6c7637e49d6ff1f7f475943685c1b3aab5c76a Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Sat, 21 Oct 2023 21:58:57 +0200 Subject: [PATCH 56/67] Partially revert "Make -pp override --paging and vice versa when passed as a later argument. (#2660)" This partially reverts commit e2bf85e749d87459e3fced697af5cd9cc96eeb8c. --- src/bin/bat/clap_app.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 33dde980..c0669c0f 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -81,7 +81,6 @@ pub fn build_app(interactive_output: bool) -> Command { Arg::new("plain") .overrides_with("plain") .overrides_with("number") - .overrides_with("paging") .short('p') .long("plain") .action(ArgAction::Count) @@ -306,7 +305,6 @@ pub fn build_app(interactive_output: bool) -> Command { .long("paging") .overrides_with("paging") .overrides_with("no-paging") - .overrides_with("plain") .value_name("when") .value_parser(["auto", "never", "always"]) .default_value("auto") From e667415deff1a8150db6cc1fc5e8db701827261d Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Sat, 21 Oct 2023 22:16:59 +0200 Subject: [PATCH 57/67] Add tests against issue #2731 --- tests/integration_tests.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index c083a941..2a192cdb 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1020,6 +1020,31 @@ fn enable_pager_if_pp_flag_comes_before_paging() { .stdout(predicate::eq("pager-output\n").normalize()); } +#[test] +fn paging_does_not_override_simple_plain() { + bat() + .env("PAGER", "echo pager-output") + .arg("--decorations=always") + .arg("--plain") + .arg("--paging=never") + .arg("test.txt") + .assert() + .success() + .stdout(predicate::eq("hello world\n")); +} + +#[test] +fn simple_plain_does_not_override_paging() { + bat() + .env("PAGER", "echo pager-output") + .arg("--paging=always") + .arg("--plain") + .arg("test.txt") + .assert() + .success() + .stdout(predicate::eq("pager-output\n")); +} + #[test] fn pager_failed_to_parse() { bat() From c9fd0f3cf0e042c1c070e01e06bc8249b35a644a Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:43:33 +0200 Subject: [PATCH 58/67] Add partial override of -pp and --paging --- src/bin/bat/app.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index d6628668..9a78c949 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -97,12 +97,30 @@ impl App { pub fn config(&self, inputs: &[Input]) -> Result { let style_components = self.style_components()?; + let extra_plain = self.matches.get_count("plain") > 1; + let plain_last_index = self + .matches + .indices_of("plain") + .and_then(Iterator::max) + .unwrap_or_default(); + let paging_last_index = self + .matches + .indices_of("paging") + .and_then(Iterator::max) + .unwrap_or_default(); + let paging_mode = match self.matches.get_one::("paging").map(|s| s.as_str()) { - Some("always") => PagingMode::Always, + Some("always") => { + // Disable paging if the second -p (or -pp) is specified after --paging=always + if extra_plain && plain_last_index > paging_last_index { + PagingMode::Never + } else { + PagingMode::Always + } + } Some("never") => PagingMode::Never, Some("auto") | None => { // If we have -pp as an option when in auto mode, the pager should be disabled. - let extra_plain = self.matches.get_count("plain") > 1; if extra_plain || self.matches.get_flag("no-paging") { PagingMode::Never } else if inputs.iter().any(Input::is_stdin) { From ac082ab64b3536d463ec922c838474f8979f1726 Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:44:53 +0200 Subject: [PATCH 59/67] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2ec2da9..a0e46c13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Fix handling of inputs with combined ANSI color and attribute sequences, see #2185 and #2856 (@eth-p) - Fix panel width when line 10000 wraps, see #2854 (@eth-p) - Fix compile issue of `time` dependency caused by standard library regression #3045 (@cyqsimon) +- Fix override behavior of --plain and --paging, see issue #2731 and PR #3108 (@einfachIrgendwer0815) ## Other From 649fb05c5859a2dca61bed165ba9965c0ac5a667 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Thu, 24 Oct 2024 01:17:17 +0200 Subject: [PATCH 60/67] Bump nix from 0.26.4 to 0.29 --- CHANGELOG.md | 1 + Cargo.lock | 17 ++++++++++++----- Cargo.toml | 2 +- tests/integration_tests.rs | 5 ++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c404042f..55879dce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ - Use bat's ANSI iterator during tab expansion, see #2998 (@eth-p) - Support 'statically linked binary' for aarch64 in 'Release' page, see #2992 (@tzq0301) - Update options in shell completions and the man page of `bat`, see #2995 (@akinomyoga) +- Update nix dev-dependency to v0.29.0, see #3112 (@decathorpe) ## Syntaxes diff --git a/Cargo.lock b/Cargo.lock index 42db6b5f..0e3b3418 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -243,6 +243,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "clap" version = "4.4.12" @@ -688,9 +694,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libgit2-sys" @@ -761,12 +767,13 @@ dependencies = [ [[package]] name = "nix" -version = "0.26.4" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "cfg-if", + "cfg_aliases", "libc", ] diff --git a/Cargo.toml b/Cargo.toml index f5ef6af9..b8fcbcbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,7 +98,7 @@ tempfile = "3.8.1" serde = { version = "1.0", features = ["derive"] } [target.'cfg(unix)'.dev-dependencies] -nix = { version = "0.26.4", default-features = false, features = ["term"] } +nix = { version = "0.29", default-features = false, features = ["term"] } [build-dependencies] anyhow = "1.0.86" diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index c083a941..13b35718 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -9,7 +9,6 @@ use tempfile::tempdir; mod unix { pub use std::fs::File; pub use std::io::{self, Write}; - pub use std::os::unix::io::FromRawFd; pub use std::path::PathBuf; pub use std::process::Stdio; pub use std::thread; @@ -416,8 +415,8 @@ fn no_args_doesnt_break() { // not exit, because in this case it is safe to read and write to the same fd, which is why // this test exists. let OpenptyResult { master, slave } = openpty(None, None).expect("Couldn't open pty."); - let mut master = unsafe { File::from_raw_fd(master) }; - let stdin_file = unsafe { File::from_raw_fd(slave) }; + let mut master = File::from(master); + let stdin_file = File::from(slave); let stdout_file = stdin_file.try_clone().unwrap(); let stdin = Stdio::from(stdin_file); let stdout = Stdio::from(stdout_file); From 9090fb75e0ae7772aa09b698a10a4f5fb04a4143 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Fri, 26 Apr 2024 16:19:07 +0200 Subject: [PATCH 61/67] Make .debdiff imply .diff using syntax_mapping toml Closes #2940 --- src/syntax_mapping/builtins/unix-family/50-diff.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/syntax_mapping/builtins/unix-family/50-diff.toml diff --git a/src/syntax_mapping/builtins/unix-family/50-diff.toml b/src/syntax_mapping/builtins/unix-family/50-diff.toml new file mode 100644 index 00000000..2998d9c5 --- /dev/null +++ b/src/syntax_mapping/builtins/unix-family/50-diff.toml @@ -0,0 +1,3 @@ +# .debdiff is the extension used for diffs in Debian packaging +[mappings] +"Diff" = ["*.debdiff"] From d0ae2e6826caf0e7701be7751989827b371b4bba Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Fri, 26 Apr 2024 16:30:39 +0200 Subject: [PATCH 62/67] Add CHANGELOG entry for .debdiff => diff --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e45f1bb1..5326de59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -114,6 +114,7 @@ - Update `Julia` syntax, see #2553 (@dependabot) - add `NSIS` support, see #2577 (@idleberg) - Update `ssh-config`, see #2697 (@mrmeszaros) +- Add syntax mapping `*.debdiff` => `diff`, see #2947 (@jacg) ## `bat` as a library From 0a8bfc52a6337828eb0d58a49006437d44ac5647 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Wed, 15 May 2024 09:07:44 +0200 Subject: [PATCH 63/67] Move from unix-family to common --- src/syntax_mapping/builtins/{unix-family => common}/50-diff.toml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/syntax_mapping/builtins/{unix-family => common}/50-diff.toml (100%) diff --git a/src/syntax_mapping/builtins/unix-family/50-diff.toml b/src/syntax_mapping/builtins/common/50-diff.toml similarity index 100% rename from src/syntax_mapping/builtins/unix-family/50-diff.toml rename to src/syntax_mapping/builtins/common/50-diff.toml From c627526f8c18ba1a1e630770b7627c159b545962 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 03:57:52 +0000 Subject: [PATCH 64/67] Bump clircle from 0.5.0 to 0.6.0 (#3117) Bumps [clircle](https://github.com/niklasmohrin/clircle) from 0.5.0 to 0.6.0. - [Release notes](https://github.com/niklasmohrin/clircle/releases) - [Commits](https://github.com/niklasmohrin/clircle/compare/v0.5.0...v0.6.0) --- updated-dependencies: - dependency-name: clircle dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 5 ++--- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e3b3418..a9b6f7dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,12 +279,11 @@ checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "clircle" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0b92245ea62a7a751db4b0e4a583f8978e508077ef6de24fcc0d0dc5311a8d" +checksum = "e136d50bd652710f1d86259a8977263d46bef0ab782a8bfc3887e44338517015" dependencies = [ "cfg-if", - "libc", "serde", "serde_derive", "winapi", diff --git a/Cargo.toml b/Cargo.toml index b8fcbcbe..a6c410b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ serde_derive = "1.0" serde_yaml = "0.9.28" semver = "1.0" path_abs = { version = "0.5", default-features = false } -clircle = "0.5" +clircle = "0.6" bugreport = { version = "0.5.0", optional = true } etcetera = { version = "0.8.0", optional = true } grep-cli = { version = "0.1.10", optional = true } From e7bef716c9ade4641f2b92e992b56837bc1d019d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 04:23:23 +0000 Subject: [PATCH 65/67] Bump encoding_rs from 0.8.34 to 0.8.35 (#3119) Bumps [encoding_rs](https://github.com/hsivonen/encoding_rs) from 0.8.34 to 0.8.35. - [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.34...v0.8.35) --- updated-dependencies: - dependency-name: encoding_rs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9b6f7dd..f8356339 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -421,9 +421,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.34" +version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ "cfg-if", ] diff --git a/Cargo.toml b/Cargo.toml index a6c410b9..ccc4ced7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,7 @@ grep-cli = { version = "0.1.10", optional = true } regex = { version = "1.10.2", optional = true } walkdir = { version = "2.5", optional = true } bytesize = { version = "1.3.0" } -encoding_rs = "0.8.34" +encoding_rs = "0.8.35" os_str_bytes = { version = "~7.0", optional = true } run_script = { version = "^0.10.1", optional = true} From 6b2c5645d251d2f3c5f58f889b8a63cf4c7ffa56 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 04:46:28 +0000 Subject: [PATCH 66/67] Bump toml from 0.8.9 to 0.8.19 (#3121) Bumps [toml](https://github.com/toml-rs/toml) from 0.8.9 to 0.8.19. - [Commits](https://github.com/toml-rs/toml/compare/toml-v0.8.9...toml-v0.8.19) --- updated-dependencies: - dependency-name: toml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8356339..f6fedcbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1146,9 +1146,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -1392,9 +1392,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "toml" -version = "0.8.9" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6a4b9e8023eb94392d3dca65d717c53abc5dad49c07cb65bb8fcd87115fa325" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "indexmap", "serde", @@ -1405,18 +1405,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.21.1" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "serde", @@ -1746,9 +1746,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176b6138793677221d420fd2f0aeeced263f197688b36484660da767bca2fa32" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index ccc4ced7..6714e6c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,7 +109,7 @@ regex = "1.10.2" serde = "1.0" serde_derive = "1.0" serde_with = { version = "3.8.1", default-features = false, features = ["macros"] } -toml = { version = "0.8.9", features = ["preserve_order"] } +toml = { version = "0.8.19", features = ["preserve_order"] } walkdir = "2.5" [build-dependencies.clap] From dbaa0a6d9eea7a594b56b535574be30b077a7a12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 05:02:22 +0000 Subject: [PATCH 67/67] Bump grep-cli from 0.1.10 to 0.1.11 (#3120) Bumps [grep-cli](https://github.com/BurntSushi/ripgrep) from 0.1.10 to 0.1.11. - [Release notes](https://github.com/BurntSushi/ripgrep/releases) - [Changelog](https://github.com/BurntSushi/ripgrep/blob/master/CHANGELOG.md) - [Commits](https://github.com/BurntSushi/ripgrep/compare/grep-cli-0.1.10...0.1.11) --- updated-dependencies: - dependency-name: grep-cli dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f6fedcbf..0f242845 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -601,9 +601,9 @@ dependencies = [ [[package]] name = "grep-cli" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea40788c059ab8b622c4d074732750bfb3bd2912e2dd58eabc11798a4d5ad725" +checksum = "47f1288f0e06f279f84926fa4c17e3fcd2a22b357927a82f2777f7be26e4cec0" dependencies = [ "bstr", "globset", diff --git a/Cargo.toml b/Cargo.toml index 6714e6c4..67327460 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,7 @@ path_abs = { version = "0.5", default-features = false } clircle = "0.6" bugreport = { version = "0.5.0", optional = true } etcetera = { version = "0.8.0", optional = true } -grep-cli = { version = "0.1.10", optional = true } +grep-cli = { version = "0.1.11", optional = true } regex = { version = "1.10.2", optional = true } walkdir = { version = "2.5", optional = true } bytesize = { version = "1.3.0" }