summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2024-01-19 09:21:23 -0500
committerGitHub <noreply@github.com>2024-01-19 09:21:23 -0500
commit9f66dc38497c93fdf6e402ba75d5dc4de1bb8051 (patch)
tree01ca30ab414e0c049faeb670f41fa190020867f7
parentfdfcc8fce30754a4f05eeb167a15d519888fc909 (diff)
--show-themes exit with error when no themes (#1611)
Fixes #587
-rw-r--r--src/subcommands/show_themes.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/subcommands/show_themes.rs b/src/subcommands/show_themes.rs
index 76590761..52c92386 100644
--- a/src/subcommands/show_themes.rs
+++ b/src/subcommands/show_themes.rs
@@ -15,6 +15,15 @@ pub fn show_themes(dark: bool, light: bool, computed_theme_is_light: bool) -> st
use super::sample_diff::DIFF;
+ let env = DeltaEnv::default();
+ let themes = get_themes(git_config::GitConfig::try_create(&env));
+ if themes.is_empty() {
+ return Err(std::io::Error::new(
+ ErrorKind::NotFound,
+ "No themes found. Please see https://dandavison.github.io/delta/custom-themes.html.",
+ ));
+ }
+
let mut input = DIFF.to_vec();
if !io::stdin().is_terminal() {
@@ -25,7 +34,6 @@ pub fn show_themes(dark: bool, light: bool, computed_theme_is_light: bool) -> st
}
};
- let env = DeltaEnv::default();
let git_config = git_config::GitConfig::try_create(&env);
let opt = cli::Opt::from_iter_and_git_config(
env.clone(),
@@ -37,7 +45,7 @@ pub fn show_themes(dark: bool, light: bool, computed_theme_is_light: bool) -> st
let title_style = ansi_term::Style::new().bold();
let writer = output_type.handle().unwrap();
- for theme in &get_themes(git_config::GitConfig::try_create(&env)) {
+ for theme in &themes {
let git_config = git_config::GitConfig::try_create(&env);
let opt = cli::Opt::from_iter_and_git_config(
env.clone(),