mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-31 02:01:05 +00:00
display which theme is the default one in colored output (#2838)
This commit is contained in:
parent
66b70dd8ed
commit
d5bd4aa93f
@ -33,6 +33,7 @@
|
|||||||
- Relax syntax mapping rule restrictions to allow brace expansion #2865 (@cyqsimon)
|
- Relax syntax mapping rule restrictions to allow brace expansion #2865 (@cyqsimon)
|
||||||
- Apply clippy fixes #2864 (@cyqsimon)
|
- Apply clippy fixes #2864 (@cyqsimon)
|
||||||
- Faster startup by offloading glob matcher building to a worker thread #2868 (@cyqsimon)
|
- Faster startup by offloading glob matcher building to a worker thread #2868 (@cyqsimon)
|
||||||
|
- Display which theme is the default one in colored output, see #2838 (@sblondon)
|
||||||
|
|
||||||
## Syntaxes
|
## Syntaxes
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ use directories::PROJECT_DIRS;
|
|||||||
use globset::GlobMatcher;
|
use globset::GlobMatcher;
|
||||||
|
|
||||||
use bat::{
|
use bat::{
|
||||||
|
assets::HighlightingAssets,
|
||||||
config::Config,
|
config::Config,
|
||||||
controller::Controller,
|
controller::Controller,
|
||||||
error::*,
|
error::*,
|
||||||
@ -200,11 +201,18 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
|
|||||||
let mut stdout = stdout.lock();
|
let mut stdout = stdout.lock();
|
||||||
|
|
||||||
if config.colored_output {
|
if config.colored_output {
|
||||||
|
let default_theme = HighlightingAssets::default_theme();
|
||||||
for theme in assets.themes() {
|
for theme in assets.themes() {
|
||||||
|
let default_theme_info = if default_theme == theme {
|
||||||
|
" (default)"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
writeln!(
|
writeln!(
|
||||||
stdout,
|
stdout,
|
||||||
"Theme: {}\n",
|
"Theme: {}{}\n",
|
||||||
Style::new().bold().paint(theme.to_string())
|
Style::new().bold().paint(theme.to_string()),
|
||||||
|
default_theme_info
|
||||||
)?;
|
)?;
|
||||||
config.theme = theme.to_string();
|
config.theme = theme.to_string();
|
||||||
Controller::new(&config, &assets)
|
Controller::new(&config, &assets)
|
||||||
|
@ -272,6 +272,24 @@ fn squeeze_limit_line_numbers() {
|
|||||||
.stdout(" 1 line 1\n 2 \n 3 \n 4 \n 5 line 5\n 6 \n 7 \n 8 \n 9 \n 10 \n 20 line 20\n 21 line 21\n 22 \n 23 \n 24 line 24\n 25 \n 26 line 26\n 27 \n 28 \n 29 \n 30 line 30\n");
|
.stdout(" 1 line 1\n 2 \n 3 \n 4 \n 5 line 5\n 6 \n 7 \n 8 \n 9 \n 10 \n 20 line 20\n 21 line 21\n 22 \n 23 \n 24 line 24\n 25 \n 26 line 26\n 27 \n 28 \n 29 \n 30 line 30\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn list_themes() {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
let default_theme_chunk = "Monokai Extended Light\x1B[0m (default)";
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
let default_theme_chunk = "Monokai Extended\x1B[0m (default)";
|
||||||
|
|
||||||
|
bat()
|
||||||
|
.arg("--color=always")
|
||||||
|
.arg("--list-themes")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(predicate::str::contains("DarkNeon").normalize())
|
||||||
|
.stdout(predicate::str::contains(default_theme_chunk).normalize())
|
||||||
|
.stdout(predicate::str::contains("Output the square of a number.").normalize());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)]
|
#[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)]
|
||||||
fn short_help() {
|
fn short_help() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user