Skip to content

Commit

Permalink
Merge pull request #2558 from itowlson/templates-dont-prompt-to-insta…
Browse files Browse the repository at this point in the history
…ll-if-not-interactive

Don't prompt to install templates if not interactive
  • Loading branch information
itowlson authored Jun 13, 2024
2 parents 98aa3e4 + 0e3c215 commit 637a9a3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/templates/src/manager.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::Path;
use std::{io::IsTerminal, path::Path};

use anyhow::Context;

Expand Down Expand Up @@ -90,10 +90,11 @@ pub struct ListResults {
}

impl ListResults {
/// Returns true if no templates were found or skipped indicating that
/// templates may not be installed.
/// Returns true if no templates were found or skipped, and the UI should prompt to
/// install templates. This is specifically for interactive use and returns false
/// if not connected to a terminal.
pub fn needs_install(&self) -> bool {
self.templates.is_empty() && self.skipped.is_empty()
self.templates.is_empty() && self.skipped.is_empty() && std::io::stderr().is_terminal()
}
}

Expand Down

0 comments on commit 637a9a3

Please sign in to comment.