matklad / xshell

Apache License 2.0
698 stars 30 forks source link

Add Error::is_not_found or similar #46

Open jplatte opened 2 years ago

jplatte commented 2 years ago

Use case: Some automation tools require other binaries to be installed. I would like to catch when that is not the case and print installation instructions.

matklad commented 2 years ago

SGTM!

Should probably add a .kind() method which returns a fieldless nonexhaustive enum.

matklad commented 1 year ago

Thinking about the broader problem, I think for myself I usually use the following pattern:

if cmd!(sh, "my-tool --version").run().is_err() {
    eprintln!("Install my tool");
    return
}

That is perhaps a better behavior than catching the error after-the-fact, because: