2023-07-30 18:40:18 +02:00
|
|
|
mod corrections;
|
|
|
|
|
mod shell;
|
|
|
|
|
mod style;
|
|
|
|
|
|
2023-07-31 01:58:37 +02:00
|
|
|
use shell::get_privilege;
|
|
|
|
|
|
2023-07-30 18:40:18 +02:00
|
|
|
fn main() {
|
|
|
|
|
std::env::set_var("LC_ALL", "C");
|
|
|
|
|
|
2023-07-30 23:48:04 +02:00
|
|
|
let shell = shell::find_shell();
|
|
|
|
|
let last_command = shell::find_last_command(&shell);
|
|
|
|
|
let corrected_command = corrections::correct_command(&shell, &last_command);
|
2023-07-31 01:58:37 +02:00
|
|
|
|
|
|
|
|
if let Some(mut corrected_command) = corrected_command {
|
2023-07-31 03:21:06 +02:00
|
|
|
if corrected_command.starts_with("sudo ") {
|
2023-07-31 01:58:37 +02:00
|
|
|
let privilege = get_privilege();
|
|
|
|
|
if let Some(privilege) = privilege {
|
|
|
|
|
if privilege != "sudo" {
|
|
|
|
|
corrected_command = corrected_command.replacen("sudo", &privilege, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-30 23:48:04 +02:00
|
|
|
corrections::confirm_correction(&shell, &corrected_command, &last_command);
|
2023-07-30 18:40:18 +02:00
|
|
|
} else {
|
2023-07-31 03:21:06 +02:00
|
|
|
println!(
|
|
|
|
|
"
|
|
|
|
|
No correction found.
|
|
|
|
|
|
|
|
|
|
If you think there should be a correction, please open an issue or send a pull request!"
|
|
|
|
|
);
|
2023-07-30 18:40:18 +02:00
|
|
|
}
|
|
|
|
|
}
|