summaryrefslogtreecommitdiff
path: root/src/check.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/check.rs')
-rwxr-xr-xsrc/check.rs25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/check.rs b/src/check.rs
index 530814f..f7e3126 100755
--- a/src/check.rs
+++ b/src/check.rs
@@ -2,7 +2,7 @@ use colored::Colorize;
use sha2::{Sha256, Digest};
use std::collections::HashMap;
use std::fs;
-use std::io::Write;
+use std::io::{Write, IsTerminal};
use std::path::{Path};
use tempfile::tempdir;
@@ -189,15 +189,22 @@ pub fn check_integrity(cfg: &Config) {
"[ror]".yellow().bold(),
broken_packages.join(", ")
);
- print!("{} Reinstall them? [y/N]: ", "[ror]".blue().bold());
- std::io::stdout().flush().ok();
- let mut answer = String::new();
- std::io::stdin().read_line(&mut answer).ok();
- if answer.trim().eq_ignore_ascii_case("y") {
- for pkg in broken_packages {
- println!("{} Reinstalling {} ...", ">>>".cyan(), pkg);
- crate::install::install_package(&pkg, cfg);
+ if std::io::stdin().is_terminal() {
+ print!("{} Reinstall them? [y/N]: ", "[ror]".blue().bold());
+ std::io::stdout().flush().ok();
+ let mut answer = String::new();
+ std::io::stdin().read_line(&mut answer).ok();
+ if answer.trim().eq_ignore_ascii_case("y") {
+ for pkg in broken_packages {
+ println!("{} Reinstalling {} ...", ">>>".cyan(), pkg);
+ crate::install::install_package(&pkg, cfg);
+ }
}
+ } else {
+ eprintln!(
+ "{} Non-interactive mode: skipping automatic reinstall of broken packages",
+ "[ror]".yellow()
+ );
}
}
}