mirror of
https://github.com/nix-community/comma.git
synced 2024-10-26 05:58:05 +03:00
Show error and exit upon nix-locate failure
Co-authored-by: gabriel-doriath-dohler <gabriel.doriath.dohler@ens.fr>
This commit is contained in:
parent
4ed30d58db
commit
1fbd317b4a
15
src/main.rs
15
src/main.rs
@ -72,12 +72,21 @@ fn main() -> ExitCode {
|
|||||||
|
|
||||||
index::check_database();
|
index::check_database();
|
||||||
|
|
||||||
let attrs = Command::new("nix-locate")
|
let nix_locate_output = Command::new("nix-locate")
|
||||||
.args(["--top-level", "--minimal", "--at-root", "--whole-name"])
|
.args(["--top-level", "--minimal", "--at-root", "--whole-name"])
|
||||||
.arg(format!("/bin/{}", command))
|
.arg(format!("/bin/{}", command))
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to execute nix-locate")
|
.expect("failed to execute nix-locate");
|
||||||
.stdout;
|
|
||||||
|
if !nix_locate_output.status.success() {
|
||||||
|
match std::str::from_utf8(&nix_locate_output.stderr) {
|
||||||
|
Ok(stderr) => eprintln!("nix-locate failed with: {}", stderr),
|
||||||
|
Err(_) => eprint!("nix-locate failed"),
|
||||||
|
}
|
||||||
|
return ExitCode::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
let attrs = nix_locate_output.stdout;
|
||||||
|
|
||||||
if attrs.is_empty() {
|
if attrs.is_empty() {
|
||||||
eprintln!("No executable `{}` found in nix-index database.", command);
|
eprintln!("No executable `{}` found in nix-index database.", command);
|
||||||
|
Loading…
Reference in New Issue
Block a user