mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2026-02-02 15:45:11 +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,
|
Some(packages) => packages,
|
||||||
None => {
|
None => {
|
||||||
eprintln!("{}: {}", "pay-respects".red(), t!("package-not-found"));
|
eprintln!("{}: {}", "pay-respects".red(), t!("package-not-found"));
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,23 @@ pub fn get_package_manager(data: &mut Data) -> Option<String> {
|
||||||
None
|
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 {
|
match package_manager {
|
||||||
"pacman" => {
|
"pacman" => {
|
||||||
let result = Command::new(shell)
|
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("-c")
|
||||||
.arg(format!("pacman -Fq /usr/bin/{}", executable))
|
.arg(format!("pacman -Fq /usr/bin/{}", executable))
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to execute process");
|
.expect("failed to execute process")
|
||||||
|
};
|
||||||
if result.status.success() {
|
if result.status.success() {
|
||||||
let output = String::from_utf8_lossy(&result.stdout)
|
let output = String::from_utf8_lossy(&result.stdout)
|
||||||
.lines()
|
.lines()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue