feat: support doas

This commit is contained in:
iff 2023-07-31 01:58:37 +02:00
parent 6bd55fb316
commit ad0eaa17fc
4 changed files with 46 additions and 18 deletions

View file

@ -2,13 +2,24 @@ mod corrections;
mod shell;
mod style;
use shell::get_privilege;
fn main() {
std::env::set_var("LC_ALL", "C");
let shell = shell::find_shell();
let last_command = shell::find_last_command(&shell);
let corrected_command = corrections::correct_command(&shell, &last_command);
if let Some(corrected_command) = corrected_command {
if let Some(mut corrected_command) = corrected_command {
if corrected_command.starts_with("sudo") {
let privilege = get_privilege();
if let Some(privilege) = privilege {
if privilege != "sudo" {
corrected_command = corrected_command.replacen("sudo", &privilege, 1);
}
}
}
corrections::confirm_correction(&shell, &corrected_command, &last_command);
} else {
println!("No correction found.");