mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 06:20:09 +01:00
fix: panic on unexpected nix-index output (github #31)
This commit is contained in:
parent
5d4da9b9df
commit
b0279716c4
1 changed files with 11 additions and 8 deletions
|
|
@ -112,18 +112,21 @@ pub fn get_packages(
|
||||||
if result.is_empty() {
|
if result.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let packages: Vec<String> = result
|
let packages: Option<Vec<String>> = result
|
||||||
.lines()
|
.lines()
|
||||||
.map(|line| {
|
.map(|line| {
|
||||||
line.split_whitespace()
|
let package = line.split_whitespace().next()?;
|
||||||
.next()
|
Some(package.rsplit_once('.')?.0.to_string())
|
||||||
.unwrap()
|
|
||||||
.rsplit_once('.')
|
|
||||||
.unwrap()
|
|
||||||
.0
|
|
||||||
.to_string()
|
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
let Some(packages) = packages else {
|
||||||
|
eprintln!(
|
||||||
|
"Unexpected output from nix-index:\n {}",
|
||||||
|
result.replace("\n", "\n ")
|
||||||
|
);
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
|
||||||
if packages.is_empty() {
|
if packages.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue