use new `bpaf::ParseFailure::exit_code`

95b5db15a8
This commit is contained in:
Scott Lamb 2023-02-11 11:49:10 -08:00
parent e21f795e93
commit b1a46cfb25
No known key found for this signature in database
3 changed files with 9 additions and 16 deletions

6
server/Cargo.lock generated
View File

@ -147,8 +147,7 @@ dependencies = [
[[package]]
name = "bpaf"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "863c0b21775e45ebf9bbb3a6d0cd9b3421c88a036e825359e3d4015561f3e23c"
source = "git+https://github.com/pacak/bpaf.git?branch=exit_code#77b8efc5d33adcf57901a03514a3ce6183144f8d"
dependencies = [
"bpaf_derive",
"owo-colors",
@ -157,8 +156,7 @@ dependencies = [
[[package]]
name = "bpaf_derive"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ed63113bfb3a9bb25dd131acdf0044c7404000ea57dd9eec1f221e3547b4748"
source = "git+https://github.com/pacak/bpaf.git?branch=exit_code#77b8efc5d33adcf57901a03514a3ce6183144f8d"
dependencies = [
"proc-macro2",
"quote",

View File

@ -24,7 +24,7 @@ members = ["base", "db"]
base = { package = "moonfire-base", path = "base" }
base64 = "0.13.0"
blake3 = "1.0.0"
bpaf = { version = "0.7.8", features = ["autocomplete", "bright-color", "derive"] }
bpaf = { git = "https://github.com/pacak/bpaf.git", branch = "exit_code", features = ["autocomplete", "bright-color", "derive"]}
bytes = "1"
byteorder = "1.0"
cursive = "0.20.0"

View File

@ -144,17 +144,12 @@ fn main() {
// TODO: remove this when bpaf adds more direct support for defaulting to `--help`.
// See discussion: <https://github.com/pacak/bpaf/discussions/165>.
if std::env::args_os().len() < 2 {
match args().run_inner(bpaf::Args::from(&["--help"])) {
Ok(a) => panic!("bpaf --help should not return Ok: {a:#?}"),
Err(bpaf::ParseFailure::Stdout(msg)) => {
print!("{msg}");
std::process::exit(0);
}
Err(bpaf::ParseFailure::Stderr(msg)) => {
eprint!("{msg}");
std::process::exit(1);
}
}
std::process::exit(
args()
.run_inner(bpaf::Args::from(&["--help"]))
.unwrap_err()
.exit_code(),
);
}
let use_panic_hook = ::std::env::var("MOONFIRE_PANIC_HOOK")