mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-11 22:10:09 +01:00
feat: use pkgfile for pacman if available
This commit is contained in:
parent
e44738e37e
commit
d10c3a55d3
2 changed files with 16 additions and 7 deletions
|
|
@ -93,7 +93,7 @@ pub fn cnf(data: &mut Data) {
|
|||
}
|
||||
};
|
||||
|
||||
let packages = match system::get_packages(&shell, &package_manager, executable) {
|
||||
let packages = match system::get_packages(data, &package_manager, executable) {
|
||||
Some(packages) => packages,
|
||||
None => {
|
||||
eprintln!("{}: {}", "pay-respects".red(), t!("package-not-found"));
|
||||
|
|
|
|||
|
|
@ -14,14 +14,23 @@ pub fn get_package_manager(data: &mut Data) -> Option<String> {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn get_packages(shell: &str, package_manager: &str, executable: &str) -> Option<Vec<String>> {
|
||||
pub fn get_packages(data: &mut Data, package_manager: &str, executable: &str) -> Option<Vec<String>> {
|
||||
let shell = &data.shell.clone();
|
||||
match package_manager {
|
||||
"pacman" => {
|
||||
let result = Command::new(shell)
|
||||
.arg("-c")
|
||||
.arg(format!("pacman -Fq /usr/bin/{}", executable))
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
let result = if data.has_executable("pkgfile") {
|
||||
Command::new(shell)
|
||||
.arg("-c")
|
||||
.arg(format!("pkgfile -b {}", executable))
|
||||
.output()
|
||||
.expect("failed to execute process")
|
||||
} else {
|
||||
Command::new(shell)
|
||||
.arg("-c")
|
||||
.arg(format!("pacman -Fq /usr/bin/{}", executable))
|
||||
.output()
|
||||
.expect("failed to execute process")
|
||||
};
|
||||
if result.status.success() {
|
||||
let output = String::from_utf8_lossy(&result.stdout)
|
||||
.lines()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue