Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--show-themes exit with error when no themes #1611

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/subcommands/show_themes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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(),
Expand All @@ -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(),
Expand Down
Loading