mirror of
https://github.com/nix-community/comma.git
synced 2024-07-14 15:30:36 +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();
|
||||
|
||||
let attrs = Command::new("nix-locate")
|
||||
let nix_locate_output = Command::new("nix-locate")
|
||||
.args(["--top-level", "--minimal", "--at-root", "--whole-name"])
|
||||
.arg(format!("/bin/{}", command))
|
||||
.output()
|
||||
.expect("failed to execute nix-locate")
|
||||
.stdout;
|
||||
.expect("failed to execute nix-locate");
|
||||
|
||||
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() {
|
||||
eprintln!("No executable `{}` found in nix-index database.", command);
|
||||
|
Loading…
Reference in New Issue
Block a user