pacak/bpaf

Failure message for `--help` contains a trailing new line

ysndr opened this issue · 0 comments

ysndr commented

The output of prog --help contains 2 final new lines, while prog --version only contains one.

The when catching the --help parse failure it is unclear whether to print stdout errors with print! or println! to maintain consistency.

The respective Docs should both either contain or omit a new line character

#[allow(dead_code)]
#[derive(Debug, Bpaf)]
#[bpaf(options, version)]
pub struct Options {
    /// Message to print in a big friendly letters
    #[bpaf(positional("MESSAGE"))]
    message: String,
}

fn main() {
    let parsed = options().run_inner(Args::current_args());

    if let Err(ParseFailure::Stdout(m,_ )) = parsed {
        println!("{:?}",m.to_string());
    };

}
$ cargo run -- --help
"Usage: prog MESSAGE\n\nAvailable positional items:\n    MESSAGE        Message to print in a big friendly letters\n\nAvailable options:\n    -h, --help     Prints help information\n    -V, --version  Prints version information\n"


$ cargo run -- --version
"Version: 0.1.0"