Add cache cleaning #13
@ -7,13 +7,14 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
pacman_api.rs
|
||||
pacman.rs
|
||||
This module provides an api to make working with Pacman much easier.
|
||||
*/
|
||||
|
||||
use std::{error, fmt, result};
|
||||
use std::fmt::Formatter;
|
||||
use std::path::Path;
|
||||
use std::process::ExitStatus;
|
||||
|
||||
use crate::shell_commands;
|
||||
|
||||
@ -64,16 +65,7 @@ pub fn check() -> Result<()> {
|
||||
pub fn update_all() -> Result<()> {
|
||||
let exit_status = shell_commands::execute_in_sh("sudo pacman -Syu")?;
|
||||
|
||||
if !exit_status.success() {
|
||||
let exit_code = match exit_status.code() {
|
||||
Some(exit_code) => exit_code,
|
||||
None => return Err(PacmanError::Other("No Exit Code Found").into()),
|
||||
};
|
||||
|
||||
return Err(PacmanError::ExitCode(exit_code).into());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
check_exit_code(exit_status)
|
||||
}
|
||||
|
||||
pub fn get_unused() -> Result<Vec<String>> {
|
||||
@ -90,9 +82,20 @@ pub fn remove_unused(packages: Vec<String>) -> Result<()> {
|
||||
let package_string = packages.join(" ");
|
||||
let command = format!("sudo pacman -Rns {}", package_string);
|
||||
|
||||
let out = shell_commands::execute_in_sh(command)?;
|
||||
let exit_status = shell_commands::execute_in_sh(command)?;
|
||||
|
||||
dbg!(&out);
|
||||
check_exit_code(exit_status)
|
||||
}
|
||||
|
||||
fn check_exit_code(exit_status: ExitStatus) -> Result<()> {
|
||||
if !exit_status.success() {
|
||||
let exit_code = match exit_status.code() {
|
||||
Some(exit_code) => exit_code,
|
||||
None => return Err(PacmanError::Other("No Exit Code Found").into()),
|
||||
};
|
||||
|
||||
return Err(PacmanError::ExitCode(exit_code).into());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user