pacak/bpaf

`ParseFailure::exit_code` no longer prints msg in 0.9.10

scottlamb opened this issue · 1 comments

My program has been doing the following for quite a while.

    let args = match args()
        .fallback_to_usage()
        .run_inner(bpaf::Args::current_args().set_name(progname))
    {
        Ok(a) => a,
        Err(e) => std::process::exit(e.exit_code()),
    };

https://github.com/scottlamb/moonfire-nvr/blob/06f942582c77ee5b99d4cc7353b0433e69fa3a9c/server/src/main.rs#L91-L97

When updating past 0.9.10 I see that running without args no longer prints usage. This was surprising in a point release and doesn't seem to be mentioned in 0.9.10's changelog either.

Looks like d987864 changed the behavior of ParseFailure::exit_code to no longer print the message. I'd call this a breaking change (major behavior of a public method dropped) although at least it fits the method name better now.

I know I'm months late to the party, but maybe at least a changelog addition would help?

btw, a couple nits:

  • the new ParseFailure::print_mesage is misspelled.
  • it's a little weird that I have to explicitly specify max_width myself. I'd like to say "do whatever you do for everything else". But looks like I can only override what's used for everything else via OptionParser::max_width, not query the current or default value. It'd be nice if the max_width were bundled into the ParseFailure, but I guess since it's an enum there's no place to stash it without an API break.

Hi Scott

Thank you for letting me know about the issues. While I do have a bunch of text covering parsing behavior - other parts are not covered as well without me realizing it. I should probably add some of those.

I'm going to update the changelog, will try to address some of the issues you pointed out in this version and look for approaches to testing it and a better api for 0.10