feat(sudo): print warning if steps were skipped due to missing sudo

This commit is contained in:
Andre Toerien
2025-09-26 15:41:38 +02:00
committed by Gideon
parent a886d20a7b
commit ad9f2c2ccb
6 changed files with 91 additions and 17 deletions

View File

@@ -25,6 +25,7 @@ use self::config::{CommandLineArgs, Config};
use self::error::StepFailed;
#[cfg(all(windows, feature = "self-update"))]
use self::error::Upgraded;
use self::runner::StepResult;
#[allow(clippy::wildcard_imports)]
use self::steps::{remote::*, *};
use self::sudo::{Sudo, SudoKind};
@@ -224,12 +225,30 @@ fn run() -> Result<()> {
if !report.is_empty() {
print_separator(t!("Summary"));
let mut skipped_missing_sudo = false;
for (key, result) in report {
if !failed && result.failed() {
failed = true;
}
if let StepResult::SkippedMissingSudo = result {
skipped_missing_sudo = true;
}
print_result(key, result);
}
if skipped_missing_sudo {
print_warning(t!(
"\nSome steps were skipped as sudo or equivalent could not be found."
));
#[cfg(unix)]
print_warning(t!(
"Install one of `sudo`, `doas`, `pkexec`, `run0` or `please` to run these steps."
));
#[cfg(windows)]
print_warning(t!("Install gsudo or enable Windows Sudo to run these steps."));
}
}
#[cfg(target_os = "linux")]