mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-19 04:21:06 +00:00
refactor: factorize constants by inverting loop and condition order
This commit is contained in:
parent
23ec433167
commit
bb4d1cbd2e
@ -201,13 +201,13 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
|
|||||||
let mut stdout = stdout.lock();
|
let mut stdout = stdout.lock();
|
||||||
|
|
||||||
let default_theme = HighlightingAssets::default_theme();
|
let default_theme = HighlightingAssets::default_theme();
|
||||||
if config.colored_output {
|
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,15 +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() {
|
|
||||||
let default_theme_info = if default_theme == theme {
|
|
||||||
" (default)"
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
};
|
|
||||||
writeln!(stdout, "{theme}{default_theme_info}")?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user