fix(sudo): set sudo flags depending on kind

This commit is contained in:
Andre Toerien
2025-06-25 19:46:49 +02:00
committed by Gideon
parent 32197f79f3
commit 012a6bbde3
4 changed files with 187 additions and 14 deletions

View File

@@ -3,6 +3,8 @@ use std::{fmt::Display, process::ExitStatus};
use rust_i18n::t;
use thiserror::Error;
use crate::sudo::SudoKind;
#[derive(Error, Debug, PartialEq, Eq)]
pub enum TopgradeError {
ProcessFailed(String, ExitStatus),
@@ -68,6 +70,26 @@ impl Display for StepFailed {
}
}
#[derive(Error, Debug)]
pub struct UnsupportedSudo<'a> {
pub sudo_kind: SudoKind,
pub option: &'a str,
}
impl Display for UnsupportedSudo<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
t!(
"{sudo_kind} does not support the {option} option",
sudo_kind = self.sudo_kind,
option = self.option
)
)
}
}
#[derive(Error, Debug)]
pub struct DryRun();