Skip to content

Commit

Permalink
Merge pull request #3168 from bash/fix-env-var-names
Browse files Browse the repository at this point in the history
Fix name of BAT_THEME_{DARK,LIGHT} env vars
  • Loading branch information
keith-hall authored Jan 9, 2025
2 parents 1321160 + 8a11a46 commit b6158c0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Features

## Bugfixes
* Fix `BAT_THEME_DARK` and `BAT_THEME_LIGHT` being ignored, see issue #3171 and PR #3168 (@bash)

## Other

Expand Down
4 changes: 2 additions & 2 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pub mod env {
/// See [`crate::theme::ThemeOptions::theme`].
pub const BAT_THEME: &str = "BAT_THEME";
/// See [`crate::theme::ThemeOptions::theme_dark`].
pub const BAT_THEME_DARK: &str = "BAT_THEME";
pub const BAT_THEME_DARK: &str = "BAT_THEME_DARK";
/// See [`crate::theme::ThemeOptions::theme_light`].
pub const BAT_THEME_LIGHT: &str = "BAT_THEME";
pub const BAT_THEME_LIGHT: &str = "BAT_THEME_LIGHT";
}

/// Chooses an appropriate theme or falls back to a default theme
Expand Down
40 changes: 40 additions & 0 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2265,6 +2265,46 @@ fn theme_arg_overrides_env_withconfig() {
.stderr("");
}

#[test]
fn theme_light_env_var_is_respected() {
bat()
.env("BAT_THEME_LIGHT", "Coldark-Cold")
.env("COLORTERM", "truecolor")
.arg("--theme=light")
.arg("--paging=never")
.arg("--color=never")
.arg("--terminal-width=80")
.arg("--wrap=never")
.arg("--decorations=always")
.arg("--style=plain")
.arg("--highlight-line=1")
.write_stdin("Lorem Ipsum")
.assert()
.success()
.stdout("\x1B[48;2;208;218;231mLorem Ipsum\x1B[0m")
.stderr("");
}

#[test]
fn theme_dark_env_var_is_respected() {
bat()
.env("BAT_THEME_DARK", "Coldark-Dark")
.env("COLORTERM", "truecolor")
.arg("--theme=dark")
.arg("--paging=never")
.arg("--color=never")
.arg("--terminal-width=80")
.arg("--wrap=never")
.arg("--decorations=always")
.arg("--style=plain")
.arg("--highlight-line=1")
.write_stdin("Lorem Ipsum")
.assert()
.success()
.stdout("\x1B[48;2;33;48;67mLorem Ipsum\x1B[0m")
.stderr("");
}

#[test]
fn theme_env_overrides_config() {
bat_with_config()
Expand Down

0 comments on commit b6158c0

Please sign in to comment.