Skip to content

Conversation

@pacak
Copy link
Contributor

@pacak pacak commented Feb 24, 2025

Positional arguments in 0.9 version of bpaf must go to the right most position.

Fixes #85

positional arguments in 0.9 version of bpaf must go to the right most
position
@pacak
Copy link
Contributor Author

pacak commented Feb 24, 2025

It is possible to add a test to catch those issues and I might do just that later once I figure out how to compile all this stuff.

Plus this restriction is going away in the next version once I get around releasing it.

@facebook-github-bot
Copy link
Contributor

@alanz has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@alanz
Copy link
Member

alanz commented Feb 24, 2025

@pacak Thanks for this. I see that there is another occurrence too. I will fix it, and add tests.

@pacak
Copy link
Contributor Author

pacak commented Feb 24, 2025

https://docs.rs/bpaf/0.9.16/bpaf/struct.OptionParser.html#method.check_invariants - this is the way to test.

@alanz
Copy link
Member

alanz commented Feb 24, 2025

I am intending to add tests like

fn eqwalize_all_help() {
, which also documents the usage.

@pacak
Copy link
Contributor Author

pacak commented Feb 24, 2025

I am intending to add tests like

This works, but you need to make sure to call --help for every nested subcommand, if they are present. With check_invariants you only need to add it on the top level. Up to you I guess.

@alanz
Copy link
Member

alanz commented Feb 24, 2025

Adding

#[cfg(test)]
mod tests {

    use bpaf::Parser;
    use super::command;

    #[test]
    fn check_options() {
        command().to_options().check_invariants(false)
    }
}

to the end of args.rs does as you say. But it sends a lot of stuff to stdout, even though the test passes. Is this expected?

@pacak
Copy link
Contributor Author

pacak commented Feb 24, 2025

But it sends a lot of stuff to stdout, even though the test passes. Is this expected?

Yes. If test succeeds - output is captured by the test runner and dropped, but if test fails - this output helps to figure out what exactly needs to be fixed.

@facebook-github-bot
Copy link
Contributor

@alanz merged this pull request in 94ecd0f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic if passing an arg like --help to commands

3 participants