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

View File

@ -24,7 +24,7 @@ members = ["base", "db"]
base = { package = "moonfire-base", path = "base" } base = { package = "moonfire-base", path = "base" }
base64 = "0.13.0" base64 = "0.13.0"
blake3 = "1.0.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" bytes = "1"
byteorder = "1.0" byteorder = "1.0"
cursive = "0.20.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`. // TODO: remove this when bpaf adds more direct support for defaulting to `--help`.
// See discussion: <https://github.com/pacak/bpaf/discussions/165>. // See discussion: <https://github.com/pacak/bpaf/discussions/165>.
if std::env::args_os().len() < 2 { if std::env::args_os().len() < 2 {
match args().run_inner(bpaf::Args::from(&["--help"])) { std::process::exit(
Ok(a) => panic!("bpaf --help should not return Ok: {a:#?}"), args()
Err(bpaf::ParseFailure::Stdout(msg)) => { .run_inner(bpaf::Args::from(&["--help"]))
print!("{msg}"); .unwrap_err()
std::process::exit(0); .exit_code(),
} );
Err(bpaf::ParseFailure::Stderr(msg)) => {
eprint!("{msg}");
std::process::exit(1);
}
}
} }
let use_panic_hook = ::std::env::var("MOONFIRE_PANIC_HOOK") let use_panic_hook = ::std::env::var("MOONFIRE_PANIC_HOOK")