bpaf supports both combinatoric and derive APIs and it’s possible to mix and match both APIs at once. Both APIs provide access to mostly the same fe

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2024-02-12 09:30:05

bpaf supports both combinatoric and derive APIs and it’s possible to mix and match both APIs at once. Both APIs provide access to mostly the same features, some things are more convenient to do with derive (usually less typing), some - with combinatoric (usually maximum flexibility and reducing boilerplate structs). In most cases using just one would suffice. Whenever possible APIs share the same keywords and overall structure. Documentation is shared and contains examples for both combinatoric and derive style.

Library allows to consume command line arguments by building up parsers for individual arguments and combining those primitive parsers using mostly regular Rust code plus one macro. For example, it’s possible to take a parser that requires a single floating point number and transform it to a parser that takes several of them or takes it optionally so different subcommands or binaries can share a lot of the code:

At any point you can apply additional validation or fallback values in terms of current parsed state of each sub-parser and you can have several stages as well:

Leave a Comment