fix(sudo): set sudo flags depending on kind
This commit is contained in:
22
src/error.rs
22
src/error.rs
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user