mirror of https://github.com/sharkdp/bat.git
Compare commits
3 Commits
203bf76420
...
1510363527
Author | SHA1 | Date |
---|---|---|
bin-ly | 1510363527 | |
Stéphane Blondon | bb4d1cbd2e | |
Stéphane Blondon | 23ec433167 |
|
@ -35,6 +35,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 basic output (no colors), see #2937 (@sblondon)
|
||||||
- Display which theme is the default one in colored output, see #2838 (@sblondon)
|
- Display which theme is the default one in colored output, see #2838 (@sblondon)
|
||||||
|
|
||||||
## Syntaxes
|
## Syntaxes
|
||||||
|
|
|
@ -200,14 +200,14 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
|
||||||
let stdout = io::stdout();
|
let stdout = io::stdout();
|
||||||
let mut stdout = stdout.lock();
|
let mut stdout = stdout.lock();
|
||||||
|
|
||||||
if config.colored_output {
|
let default_theme = HighlightingAssets::default_theme();
|
||||||
let default_theme = HighlightingAssets::default_theme();
|
for theme in assets.themes() {
|
||||||
for theme in assets.themes() {
|
let default_theme_info = if default_theme == theme {
|
||||||
let default_theme_info = if default_theme == theme {
|
" (default)"
|
||||||
" (default)"
|
} else {
|
||||||
} else {
|
""
|
||||||
""
|
};
|
||||||
};
|
if config.colored_output {
|
||||||
writeln!(
|
writeln!(
|
||||||
stdout,
|
stdout,
|
||||||
"Theme: {}{}\n",
|
"Theme: {}{}\n",
|
||||||
|
@ -219,7 +219,12 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
|
||||||
.run(vec![theme_preview_file()], None)
|
.run(vec![theme_preview_file()], None)
|
||||||
.ok();
|
.ok();
|
||||||
writeln!(stdout)?;
|
writeln!(stdout)?;
|
||||||
|
} else {
|
||||||
|
writeln!(stdout, "{theme}{default_theme_info}")?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.colored_output {
|
||||||
writeln!(
|
writeln!(
|
||||||
stdout,
|
stdout,
|
||||||
"Further themes can be installed to '{}', \
|
"Further themes can be installed to '{}', \
|
||||||
|
@ -228,10 +233,6 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
|
||||||
https://github.com/sharkdp/bat#adding-new-themes",
|
https://github.com/sharkdp/bat#adding-new-themes",
|
||||||
config_dir.join("themes").to_string_lossy()
|
config_dir.join("themes").to_string_lossy()
|
||||||
)?;
|
)?;
|
||||||
} else {
|
|
||||||
for theme in assets.themes() {
|
|
||||||
writeln!(stdout, "{theme}")?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -273,7 +273,7 @@ fn squeeze_limit_line_numbers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn list_themes() {
|
fn list_themes_with_colors() {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let default_theme_chunk = "Monokai Extended Light\x1B[0m (default)";
|
let default_theme_chunk = "Monokai Extended Light\x1B[0m (default)";
|
||||||
|
|
||||||
|
@ -290,6 +290,23 @@ fn list_themes() {
|
||||||
.stdout(predicate::str::contains("Output the square of a number.").normalize());
|
.stdout(predicate::str::contains("Output the square of a number.").normalize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn list_themes_without_colors() {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
let default_theme_chunk = "Monokai Extended Light (default)";
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
let default_theme_chunk = "Monokai Extended (default)";
|
||||||
|
|
||||||
|
bat()
|
||||||
|
.arg("--color=never")
|
||||||
|
.arg("--list-themes")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(predicate::str::contains("DarkNeon").normalize())
|
||||||
|
.stdout(predicate::str::contains(default_theme_chunk).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…
Reference in New Issue